Part Number Hot Search : 
2SK37 6KE12 BM29F 70280 CNY17F CA0358AE HMC128G8 MIW5047
Product Description
Full Text Search
 

To Download MC68HC11 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  order this document by m68hc11rm/ad rev. 3.0 non-disclosure agreement required m68hc11 reference manual hc11 hc11 hc11
non-disclosure agreement required motorola reserves the right to make changes without further notice to any products herein to improve reliability, function or design. motorola does not assume any liability arising out of the application or use of any product or circuit described herein; neither does it convey any license under its patent rights nor the rights of others. motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the motorola product could create a situation where personal injury or death may occur. should buyer purchase or use motorola products for any such unintended or unauthorized application, buyer shall indemnify and hold motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that motorola was negligent regarding the design or manufacture of the part.
table of contents paragraph number page number m68hc11 table of contents motorola reference manual iii section 1 general description 1.1 general description of the MC68HC11a8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 1.2 programmers model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 1.3 product derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 section 2 pins and connections 2.1 packages and pin names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 2.1.1 MC68HC11a8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 -1 2.1.2 MC68HC11d3/711d3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 2.1.3 MC68HC11e9/711e9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 2.1.4 mc68hc811e2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2- 4 2.1.5 MC68HC11f1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 2.1.6 mc68hc24 port replacement unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 2.2 pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 2.2.1 power-supply pins (v dd and v ss ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 2.2.2 mode select pins (modb/v stby and moda/ lir) . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 2.2.3 crystal oscillator and clock pins (extal, xtal, and e) . . . . . . . . . . . . . . . . . . . . 2-11 2.2.4 crystal oscillator application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15 2.2.4.1 crystals for parallel resonance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15 2.2.4.2 using crystal oscillator outputs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15 2.2.4.3 using external oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15 2.2.4.4 at-strip vs at-cut crystals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16 2.2.5 reset pin (reset). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 6 2.2.6 interrupt pins (xirq, irq) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17 2.2.7 a/d reference and port e pins (v refl , v refh , pe[7:0]) . . . . . . . . . . . . . . . . . . . . . 2-18 2.2.8 timer port a pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 -19 2.2.9 serial port d pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19 2.2.10 ports b and c, stra, and strb pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20 2.3 termination of unused pins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21 2.4 avoidance of pin damage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 2.4.1 zap and latchup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 -24 2.4.2 protective interface circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24 2.4.3 internal circuitry digital input-only pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25 2.4.4 internal circuitry analog input-only pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26 2.4.5 internal circuitry digital i/o pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28 2.4.6 internal circuitry input/open-drain-output pin . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29 2.4.7 internal circuitry digital output-only pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29 2.4.8 internal circuitry modb/vstby pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30 2.4.9 internal circuitry irq/v ppbulk pin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31 2.5 typical single-chip-mode system connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31 2.6 typical expanded-mode-system connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33 2.7 system development and debug features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37 2.7.1 load instruction register ( lir). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37 2.7.2 internal read visibility (irv). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37 2.7.3 mc68hc24 port replacement unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
paragraph number page number motorola table of contents m68hc11 iv reference manual section 3 configuration and modes of operation 3.1 hardware mode selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1 3.1.1 hardware mode select pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 3.1.2 mode control bits in the hprio register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 3.2 eeprom-based config register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 3.2.1 operation of config mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 3.2.2 the config register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3.3 protected control register bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6 3.3.1 ram and i/o mapping register (init) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6 3.3.2 protected control bits in the tmsk2 register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8 3.3.3 protected control bits in the option register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 3.4 normal mcu operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10 3.4.1 normal single-chip mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10 3.4.2 normal expanded mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10 3.5 special mcu operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11 3.5.1 testing functions control register (test1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12 3.5.2 test-related control bits in the baud register . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14 3.5.3 special test mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3- 14 3.5.4 special bootstrap mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15 3.5.4.1 loading programs in bootstrap mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16 3.5.4.2 executing user programs in bootstrap mode . . . . . . . . . . . . . . . . . . . . . . . . . 3-16 3.5.4.3 using interrupts in bootstrap mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17 3.5.4.4 bootloader firmware options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18 3.6 test and bootstrap mode applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19 section 4 on-chip memory 4.1 rom. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1 4.2 ram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 4.2.1 remapping using the init register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 4.2.2 ram standby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3 4.3 eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4 4.3.1 logical and physical organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4 4.3.2 basic operation of the eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5 4.3.3 systems operating below 2-mhz bus speed (e clock). . . . . . . . . . . . . . . . . . . . . . . 4-9 4.3.4 eeprom programming register (pprog). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10 4.3.5 programming/erasing procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12 4.3.5.1 programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12 4.3.5.2 bulk erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1 2 4.3.5.3 row erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13 4.3.5.4 byte erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1 3 4.3.5.5 config register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13 4.3.6 optional eeprom security mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14 4.4 eeprom application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16 4.4.1 conditions and practices to avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16 4.4.2 using eeprom to select product options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18 4.4.3 using eeprom for setpoint and calibration information . . . . . . . . . . . . . . . . . . . . 4-18 4.4.4 using eeprom during product development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19 4.4.5 logging data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19 4.4.6 self-adjusting systems using eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20 4.4.7 software methods to extend life expectancy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21
paragraph number page number m68hc11 table of contents motorola reference manual v section 5 resets and interrupts 5.1 initial conditions established during reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1 5.1.1 system initial conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5- 2 5.1.1.1 cpu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 5.1.1.2 memory map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 5.1.1.3 parallel i/o . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 5.1.1.4 timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 5.1.1.5 real-time interrupt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 5.1.1.6 pulse accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 5.1.1.7 cop watchdog. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 5.1.1.8 serial communications interface (sci) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 5.1.1.9 serial peripheral interface (spi). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 5.1.1.10 analog-to-digital (a/d) converter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 5.1.1.11 other system controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 5.1.2 config register allows flexible configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 5.1.3 mode of operation established . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5 5.1.4 program counter loaded with reset vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5 5.2 causes of reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5 5.2.1 power-on reset (por) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7 5.2.2 cop watchdog timer reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7 5.2.3 clock monitor reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 -9 5.2.4 external reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10 5.3 interrupt process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11 5.3.1 interrupt recognition and stacking registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12 5.3.2 selecting interrupt vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12 5.3.3 return from interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5- 20 5.4 non-maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20 5.4.1 non-maskable interrupt request (xirq) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21 5.4.2 illegal opcode fetch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5- 22 5.4.3 software interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23 5.5 maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23 5.5.1 i bit in the condition code register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23 5.5.2 special considerations for i-bit-related instructions . . . . . . . . . . . . . . . . . . . . . . . . 5-24 5.6 interrupt request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25 5.6.1 selecting edge triggering or level triggering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25 5.6.2 sharing vector with handshake i/o interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26 5.7 interrupts from internal peripheral subsystems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26 5.7.1 inhibiting individual sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27 5.7.2 clearing interrupt status flag bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27 5.7.3 automatic clearing mechanisms on some flags . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27 section 6 central processing unit 6.1 programmers model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1 6.1.1 accumulators (a, b, and d) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1 6.1.2 index registers (x and y) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 6.1.3 stack pointer (sp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3 6.1.4 program counter (pc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 6.1.5 condition code register (ccr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 6.2 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6 6.2.1 immediate (imm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
paragraph number page number motorola table of contents m68hc11 vi reference manual 6.2.2 extended (ext) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7 6.2.3 direct (dir). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8 6.2.4 indexed (indx, indy) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9 6.2.5 inherent (inh) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-10 6.2.6 relative (rel) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-10 6.3 m68hc11 instruction set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11 6.3.1 accumulator and memory instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11 6.3.1.1 loads, stores, and transfers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11 6.3.1.2 arithmetic operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12 6.3.1.3 multiply and divide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13 6.3.1.4 logical operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-14 6.3.1.5 data testing and bit manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-14 6.3.1.6 shifts and rotates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-14 6.3.2 stack and index register instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15 6.3.3 condition code register instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-17 6.3.4 program control instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-17 6.3.4.1 branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1 8 6.3.4.2 jumps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 -19 6.3.4.3 subroutine calls and returns (bsr, jsr, rts) . . . . . . . . . . . . . . . . . . . . . . . 6-19 6.3.4.4 interrupt handling (rti, swi, wai) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-19 6.3.4.5 miscellaneous (nop, stop, test). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-19 section 7 parallel input/output 7.1 parallel i/o overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1 7.2 parallel i/o register and control bit explanations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3 7.2.1 port registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4 7.2.2 data direction registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7- 5 7.3 detailed i/o pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6 7.3.1 port a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7 7.3.1.1 pa[2:0] (ic[3:1]) pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7 7.3.1.2 pa[6:3] (oc[5:2]) pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7 7.3.1.3 pa7 (oc1, pai) pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8 7.3.1.4 port a idealized timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11 7.3.2 port b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11 7.3.2.1 port b pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12 7.3.2.2 port b idealized timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13 7.3.2.3 special considerations for port b on mc68hc24 pru . . . . . . . . . . . . . . . . . 7-13 7.3.3 r/w (strb) pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7- 14 7.3.3.1 r/w (strb) pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14 7.3.3.2 special considerations for strb on mc68hc24 pru . . . . . . . . . . . . . . . . . . 7-16 7.3.4 port c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16 7.3.4.1 port c pin logic for expanded modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16 7.3.4.2 summary of port c idealized expanded-mode timing . . . . . . . . . . . . . . . . . . 7-17 7.3.4.3 port c single-chip mode pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18 7.3.4.4 port c idealized single-chip mode timing. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21 7.3.4.5 special considerations for port c on mc68hc24 pru . . . . . . . . . . . . . . . . . . 7-23 7.3.5 as (stra) pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-23 7.3.5.1 as (stra) pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-23 7.3.5.2 special considerations for stra on mc68hc24 pru . . . . . . . . . . . . . . . . . . 7-25 7.3.6 port d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-25 7.3.6.1 pd0 (rxd) pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-25
paragraph number page number m68hc11 table of contents motorola reference manual vii 7.3.6.2 pd1 (txd) pin logic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-27 7.3.6.3 pd2 (miso) pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-29 7.3.6.4 pd3 (mosi) pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-31 7.3.6.5 pd4 (sck) pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-33 7.3.6.6 pd5 (ss) pin logic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-35 7.3.6.7 idealized port d timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-37 7.3.7 port e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-39 7.3.7.1 port e pin logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-39 7.3.7.2 idealized port e timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-40 7.4 handshake i/o subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7- 41 7.4.1 simple strobe mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-42 7.4.1.1 port b strobe output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-42 7.4.1.2 port c simple latching input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43 7.4.2 full-input handshake mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43 7.4.3 full-output handshake mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-44 7.4.3.1 normal output handshake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-45 7.4.3.2 three-state variation of output handshake . . . . . . . . . . . . . . . . . . . . . . . . . . 7-45 7.4.4 parallel i/o control register (pioc). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-46 7.4.5 non-handshake uses of stra and strb pins . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-48 section 8 synchronous serial peripheral interface 8.1 spi transfer formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1 8.1.1 spi clock phase and polarity controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1 8.1.2 cpha equals zero transfer format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 8.1.3 cpha equals one transfer format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 8.2 spi block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3 8.3 spi pin signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4 8.4 spi registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6 8.4.1 port d data direction control register (ddrd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6 8.4.2 spi control register (spcr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7 8.4.3 spi status register (spsr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8 8.5 spi system errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-9 8.5.1 spi mode-fault error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 -9 8.5.2 spi write-collision errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10 8.6 beginning and ending spi transfers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10 8.6.1 transfer beginning period (initiation delay) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-11 8.6.2 transfer ending period. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12 8.7 transfers to peripherals with odd word lengths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-14 8.7.1 example 8C1: on-chip spi driving an mc144110 d/a . . . . . . . . . . . . . . . . . . . . . . 8-16 8.7.2 example 8C2: software spi driving an mc144110 d/a . . . . . . . . . . . . . . . . . . . . . . 8-16 section 9 asynchronous serial communications interface 9.1 general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1 9.1.1 transmitter block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1 9.1.2 receiver block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 9.2 sci registers and control bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5 9.2.1 port d related registers and control bits (portd, ddrd, spcr) . . . . . . . . . . . . . 9-6 9.2.2 baud-rate control register (baud) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7 9.2.3 sci control register 1 (sccr1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9 9.2.4 sci control register 2 (sccr2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10
paragraph number page number motorola table of contents m68hc11 viii reference manual 9.2.5 sci status register (scsr). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-11 9.2.6 sci data register (scdr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14 9.3 sci transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14 9.3.1 eight- and nine-bit data modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15 9.3.2 interrupts and status flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-16 9.3.3 send break. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-16 9.3.4 queued idle character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-17 9.3.5 disabling the sci transmitter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-18 9.3.6 txd pin buffer logic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9- 18 9.4 sci receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-20 9.4.1 data sampling technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-20 9.4.2 worst-case baud-rate mismatch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-26 9.4.3 double-buffered operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-28 9.4.4 receive status flags and interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-28 9.4.5 receiver wake-up operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-29 9.5 baud-rate generator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-30 9.5.1 timing chain block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-30 9.5.2 baud rates vs. crystal frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-30 9.6 sci timing details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-30 9.6.1 operation as transmitter is enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-31 9.6.2 tdre and transfers from scdr to transmit shift register . . . . . . . . . . . . . . . . . . 9-33 9.6.3 tc vs. character completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-34 9.6.4 rdrf flag setting vs. end of a received character. . . . . . . . . . . . . . . . . . . . . . . . 9-35 section 10 main timer and real-time interrupt 10.1 general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1 10.1.1 overall timer block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2 10.1.2 input-capture concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2 10.1.3 output-compare concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-4 10.2 free-running counter and prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-5 10.2.1 overall clock divider structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-5 10.2.1.1 prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10- 7 10.2.1.2 overflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10 10.2.1.3 counter bypass (test mode) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-11 10.2.2 real-time interrupt (rti) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-11 10.2.3 cop watchdog function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13 10.2.4 tips for clearing timer flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14 10.3 input-capture functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-15 10.3.1 programmable options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17 10.3.2 using input capture to measure period and frequency . . . . . . . . . . . . . . . . . . . 10-18 10.3.3 using input capture to measure pulse width . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20 10.3.4 measuring very short time periods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-24 10.3.5 measuring long time periods with input capture and overflow . . . . . . . . . . . . . 10-24 10.3.6 establishing a relationship between software and an event . . . . . . . . . . . . . . . 10-27 10.3.7 other uses for input-capture pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-28 10.4 output-compare functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2 8 10.4.1 normal i/o pin control using oc[5:2] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-32 10.4.2 advanced i/o pin control using oc1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-35 10.4.2.1 one output compare controlling up to five pins . . . . . . . . . . . . . . . . . . . . 10-35 10.4.2.2 two output compares controlling one pin . . . . . . . . . . . . . . . . . . . . . . . . . 10-36
paragraph number page number m68hc11 table of contents motorola reference manual ix 10.4.3 forced output compares . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-38 10.5 timing details for the main timer system. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-39 10.6 listing of timer examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0-42 section 11 pulse accumulator 11.1 general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1 11.1.1 pulse accumulator block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2 11.1.2 pulse accumulator control and status registers. . . . . . . . . . . . . . . . . . . . . . . . . . 11-3 11.2 event counting mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6 11.2.1 interrupting after n events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6 11.2.2 counting more than 256 events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6 11.3 gated time accumulation mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7 11.3.1 measuring times longer than the range of the 8-bit counter . . . . . . . . . . . . . . . 11-8 11.3.2 configuring for interrupt after a specified time . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9 11.4 other uses for the pai pin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9 11.5 timing details for the pulse accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9 section 12 analog-to-digital converter system 12.1 charge-redistribution a/d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1 12.2 a/d converter implementation on MC68HC11a8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-12 12.2.1 MC68HC11a8 successive-approximation a/d converter . . . . . . . . . . . . . . . . . . 12-12 12.2.2 a/d charge pump and resistor-capacitor (rc) oscillator . . . . . . . . . . . . . . . . . 12-13 12.2.3 MC68HC11a8 a/d system control logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-14 12.2.4 a/d control/status register (adctl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-15 12.2.5 a/d result registers (adr[4:1]) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17 12.3 a/d pin connection considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17 appendix a instruction set details a.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a -1 a.2 nomenclature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a-1 appendix b bootloader listings index
motorola table of contents m68hc11 x reference manual
figure title page list of figures m68hc11 list of figures motorola reference manual xi 1-1 block diagram ................................................................................................ 1-3 1-2 m68hc11 programmers model ..................................................................... 1-4 1-3 part numbering .............................................................................................. 1-5 2-1 MC68HC11a8 pin assignments .................................................................... 2-2 2-2 MC68HC11d3/711d3 pin assignments ......................................................... 2-3 2-3 MC68HC11e9/711e9 pin assignments (52-pin plcc) ................................. 2-4 2-4 mc68hc811e2 pin assignments (48-pin dip) .............................................. 2-5 2-5 MC68HC11f1 pin assignments (68-pin plcc) ............................................ 2-6 2-6 mc68hc24 pin assignments ......................................................................... 2-7 2-7 reduced idd moda/ lir connections ........................................................ 2-10 2-8 ram standby modb/v stby connections .................................................... 2-11 2-9 high-frequency crystal connections ........................................................... 2-12 2-10 low-frequency crystal connections ........................................................... 2-12 2-11 crystal layout example ............................................................................... 2-13 2-12 reset circuit example .................................................................................. 2-17 2-13 low-pass filter for a/d reference pins ....................................................... 2-19 2-14 cmos inverter ............................................................................................. 2-22 2-15 internal circuitry digital input-only pin .................................................... 2-25 2-16 internal circuitry analog input-only pin ................................................... 2-27 2-17 internal circuitry digital i/o pin ................................................................ 2-28 2-18 internal circuitry input/open-drain-output pin ........................................ 2-29 2-19 internal circuitry output-only pin ............................................................ 2-29 2-20 internal circuitry modb/v stby pin .......................................................... 2-30 2-21 internal circuitry irq/v ppbulk pin .......................................................... 2-31 2-22 basic single-chip-mode connections .......................................................... 2-32 2-23 basic expanded mode connections (sheet 1 of 2) ...................................... 2-35 2-24 basic expanded mode connections (sheet 2 of 2) ...................................... 2-36 3-1 schematic for figure 3-3 (sheet 1 of 2) ....................................................... 3-21 3-2 schematic for figure 3-3 (sheet 2 of 2) ....................................................... 3-22 3-3 program to check/change config ............................................................ 3-23 4-1 topological arrangement of eeprom bytes (MC68HC11a8) ...................... 4-5 4-2 topological arrangement of bits in an eeprom byte ................................... 4-5 4-3 condensed schematic of eeprom array ..................................................... 4-6 4-4 eeprom cell terminology ............................................................................ 4-7 4-5 erasing an eeprom byte ............................................................................. 4-7 4-6 programming an eeprom byte .................................................................... 4-8 4-7 reading an eeprom byte ............................................................................ 4-9 4-8 erase-before-write programming method ................................................... 4-24
figure title page motorola list of figures m68hc11 xii reference manual 4-9 program-more-zeros programming method ................................................ 4-24 4-10 selective-write programming method .......................................................... 4-25 4-11 composite programming method ................................................................. 4-26 5-1 typical external reset circuit ...................................................................... 5-11 5-2 processing flow out of resets (sheet 1 of 2) .............................................. 5-16 5-3 processing flow out of resets (sheet 2 of 2) .............................................. 5-17 5-4 interrupt priority resolution (sheet 1 of 2) ................................................... 5-18 5-5 interrupt priority resolution (sheet 2 of 2) ................................................... 5-19 5-6 interrupt source resolution within sci ........................................................ 5-20 6-1 m68hc11 programmers model ..................................................................... 6-2 7-1 parallel i/o registers and control bits ........................................................... 7-3 7-2 pin logic registers and control bits .............................................................. 7-4 7-3 special symbols used in pin logic diagrams ................................................ 7-6 7-4 pa[2:0] (ic[3:1]) pin logic .............................................................................. 7-7 7-5 pa[6:3] (oc[5:2]) pin logic ............................................................................ 7-9 7-6 pa7 (oc1, pai) pin logic ............................................................................ 7-10 7-7 idealized port a timing ................................................................................ 7-11 7-8 port b pin logic ............................................................................................ 7-12 7-9 idealized port b timing ................................................................................ 7-13 7-10 r/w (strb) pin logic .................................................................................. 7-15 7-11 port c expanded mode pin logic ................................................................ 7-17 7-12 summary of idealized port c expanded-mode timing ................................ 7-19 7-13 port c single-chip mode pin logic .............................................................. 7-20 7-14 idealized port c single-chip mode timing .................................................. 7-22 7-15 as (stra) pin logic .................................................................................... 7-24 7-16 pd0 (rxd) pin logic .................................................................................... 7-26 7-17 pd1 (txd) pin logic ..................................................................................... 7-28 7-18 pd2 (miso) pin logic .................................................................................. 7-30 7-19 pd3 (mosi) pin logic .................................................................................. 7-32 7-20 pd4 (sck) pin logic .................................................................................... 7-34 7-21 pd5 (ss) pin logic ...................................................................................... 7-36 7-22 idealized port d timing ................................................................................ 7-38 7-23 port e pin logic ............................................................................................ 7-40 7-24 idealized port e timing ................................................................................ 7-41 7-25 idealized timing for simple strobe operations ............................................ 7-42 7-26 idealized timing for full-input handshake ................................................... 7-44 7-27 idealized timing for full-output handshake ................................................ 7-45
figure title page m68hc11 list of figures motorola reference manual xiii 8-1 cpha equals zero spi transfer format ....................................................... 8-2 8-2 cpha equals one spi transfer format ........................................................ 8-3 8-3 spi system block diagram ............................................................................ 8-4 8-4 delay from write spdr to transfer start (master) ...................................... 8-12 8-5 transfer ending for an spi master ............................................................... 8-13 8-6 transfer ending for an spi slave ................................................................. 8-14 8-7 hardware hookup for examples 8C1 and 8C2 ............................................. 8-15 8-8 register definitions and ram variables for examples 8C1 and 8C2 ........... 8-16 8-9 example 8C1 software listing (sheet 1 of 2) ............................................... 8-17 8-10 timing analysis for example 8C1 ................................................................. 8-19 8-11 example 8C2 software listing ...................................................................... 8-20 8-12 timing analysis for example 8C2 (sheet 1 of 2) .......................................... 8-21 9-1 sci transmitter block diagram ...................................................................... 9-2 9-2 sci receiver block diagram .......................................................................... 9-4 9-3 txd pin logic block diagram ....................................................................... 9-19 9-4 start bit ideal case .................................................................................. 9-22 9-5 start bit noise case one ......................................................................... 9-22 9-6 start bit noise case two ......................................................................... 9-23 9-7 start bit noise case three ...................................................................... 9-24 9-8 start bit noise case four ........................................................................ 9-24 9-9 start bit noise case five ......................................................................... 9-25 9-10 start bit noise case six .......................................................................... 9-25 9-11 baud-rate frequency tolerance ................................................................. 9-27 9-12 baud-rate generator block diagram ........................................................... 9-31 9-13 transmitter enable timing details ............................................................... 9-33 9-14 write scdr to serial data start .................................................................. 9-34 9-15 ending details of transmission .................................................................... 9-35 9-16 rdrf flag-setting details ........................................................................... 9-36 10-1 main timer system block diagram .............................................................. 10-3 10-2 timing summary for oscillator divider signals ............................................ 10-6 10-3 major clock divider chains in the MC68HC11a8 ........................................ 10-9 10-4 measuring a period with input capture ...................................................... 10-19 10-5 timing analysis for example 10C1 ............................................................. 10-19 10-6 measuring a pulse width with input capture ............................................. 10-22 10-7 timing analysis for example 10C2 ............................................................. 10-23 10-8 measuring long periods with input capture and tof (sheet 1 of 2) ........ 10-26 10-9 simple output-compare example .............................................................. 10-31 10-10 generating a square wave with output compare ..................................... 10-33 10-11 timing analysis for example 10C5 ............................................................. 10-34
figure title page motorola list of figures m68hc11 xiv reference manual 10-12 producing two pwm outputs with oc1, oc2, and oc3 .......................... 10-37 10-13 timer counter as mcu leaves reset ....................................................... 10-40 10-14 timer counter read cycle-by-cycle analysis ....................................... 10-40 10-15 input-capture timing details ...................................................................... 10-41 10-16 output-compare timing details ................................................................. 10-42 11-1 pulse accumulator operating modes ........................................................... 11-1 11-2 block diagram of pulse accumulator subsystem ........................................ 11-3 11-3 pulse accumulator control and status register summary .......................... 11-4 11-4 pai pin edge-detection timing .................................................................. 11-10 11-5 pin enable vs. counting (gated accumulation mode) ............................... 11-10 11-6 timing details for pulse accumulator counter overflow ........................... 11-11 11-7 pacnt read and write ............................................................................. 11-12 12-1 basic charge-redistribution a/d .................................................................. 12-2 12-2 charge-redistribution a/d with 1/2 lsb quantization error ..................... 12-9 12-3 MC68HC11a8 a/d in sample mode .......................................................... 12-12 12-4 timing diagram for a sequence of four a/d conversions ........................ 12-15 12-5 electrical model of an a/d input pin (sample mode) ................................. 12-17 12-6 graphic estimation of analog sample level (case 2) ............................... 12-21
table title page list of tables m68hc11 list of tables motorola reference manual xv 1-1 m68hc11 family members ................................................................................. 1-6 2-1 hardware mode select summary.......................................................................... 2-9 2-2 ports b and c, stra, and strb pins ................................................................ 2-21 3-1 hardware mode select summary.......................................................................... 3-2 3-2 watchdog rates vs. crystal frequency .............................................................. 3-10 3-3 bootstrap mode pseudo-vectors......................................................................... 3-18 5-1 hardware mode select summary.......................................................................... 5-5 5-2 reset vector vs. cause and mcu mode............................................................... 5-6 5-3 watchdog rates vs. crystal frequency ................................................................ 5-8 5-4 highest priority 1 interrupt vs. psel[3:0] ............................................................ 5-14 9-1 baud-rate prescale selects.................................................................................. 9-8 9-2 baud-rate selects................................................................................................. 9-9 9-3 baud rates by crystal frequency, scp[1:0] and scr[2:0] .............................. 9-32 10-1 crystal frequency vs. pr1, pr0 values ......................................................... 10-10 10-2 rti rates vs. rtr1, rtr0 for various crystal frequencies.......................... 10-13 10-3 cop time-out vs. cr1, cr0 values .............................................................. 10-14 10-4 instruction sequences to clear tof .............................................................. 10-15 11-1 pulse accumulator timing periods vs. crystal rate ......................................... 11-2

m68hc11 general description motorola reference manual 1-1 section 1 general description this reference manual will be a valuable aid in the development of m68hc11 applica- tions. detailed descriptions of all internal subsystems and functions have been devel- oped and carefully checked against internal motorola design documentation, making this manual the most comprehensive reference available for the m68hc11 family of microcontroller units (mcus). practical applications are included to demonstrate the operation of each subsystem. these applications are treated as complete systems, including hardware/software in- teractions and trade-offs. interfacing techniques to prevent component damage are discussed to aid the hardware designer. for software programmers, section 6 central processing unit and appendix a instruction set details contain examples demonstrating efficient use of the instruction set. this manual is intended to complement motorolas official data sheet, not replace it. the information in the data sheet is current and is guaranteed by production testing. although the information in this manual was checked against parts and design docu- mentation, the accuracy is not guaranteed like the data sheet is guaranteed. this man- ual assumes the reader has some basic knowledge of mcus and assembly-language programming; it may not be appropriate as an instruction manual for a first-time mcu user. the information in this manual is much more detailed than would usually be required for normal use of the mcu, but a user who is familiar with the detailed operation of the part is more likely to find a solution to an unexpected system problem. in many cases, a trick based on software or on-chip resources can be used rather than building ex- pensive external circuitry. data sheets are geared toward customary, straightforward use of the on-chip peripherals; whereas, an experienced mcu user often uses these on-chip systems in very unexpected ways. the level of detail in this manual will help the normal user to better understand the on-chip systems and will allow the more ad- vanced user to make maximum use of the subtleties of these systems. in addition to this manual, the data sheet(s) or technical summary is needed for the specific version(s) of the m68hc11 being used. a pocket reference guide is another beneficial source. 1.1 general description of the MC68HC11a8 the hcmos MC68HC11a8 is an advanced 8-bit mcu with highly sophisticated, on- chip peripheral capabilities. new design techniques were used to achieve a nominal bus speed of 2 mhz. in addition, the fully static design allows operation at frequencies down to dc, further reducing power consumption. the hcmos technology used on the MC68HC11a8 combines smaller size and higher
motorola general description m68hc11 1-2 reference manual speeds with the low power and high noise immunity of cmos. on-chip memory sys- tems include 8 kbytes of read-only memory (rom), 512 bytes of electrically erasable programmable rom (eeprom), and 256 bytes of random-access memory (ram). major peripheral functions are provided on-chip. an eight-channel analog-to-digital (a/ d) converter is included with eight bits of resolution. an asynchronous serial commu- nications interface (sci) and a separate synchronous serial peripheral interface (spi) are included. the main 16-bit, free-running timer system has three input-capture lines, five output-compare lines, and a real-time interrupt function. an 8-bit pulse accumula- tor subsystem can count external events or measure external periods. self-monitoring circuitry is included on-chip to protect against system errors. a com- puter operating properly (cop) watchdog system protects against software failures. a clock monitor system generates a system reset in case the clock is lost or runs too slow. an illegal opcode detection circuit provides a non-maskable interrupt if an illegal opcode is detected. two software-controlled power-saving modes, wait and stop, are available to con- serve additional power. these modes make the m68hc11 family especially attractive for automotive and battery-driven applications. figure 1-1 is a block diagram of the MC68HC11a8 mcu. this diagram shows the ma- jor subsystems and how they relate to the pins of the mcu. in the lower right-hand cor- ner of this diagram, the parallel i/o subsystem is shown inside a dashed box. the functions of this subsystem are lost when the mcu is operated in expanded modes, but the mc68hc24 port replacement unit can be used to regain the functions that were lost. the functions are restored in such a way that the software programmer is unable to tell any difference between a single-chip system or an expanded system containing the mc68hc24. by using an expanded system containing an mc68hc24 and an ex- ternal eprom, the user can develop software intended for a single-chip application. 1.2 programmers model in addition to executing all m6800 and m6801 instructions, the m68hc11 instruction set includes 91 new opcodes. the nomenclature m68xx is used in conjunction with a specific cpu architecture and instruction set as opposed to the MC68HC11xx nomen- clature, which is a reference to a specific member of the m68hc11 family of mcus. figure 1-2 shows the seven cpu registers available to the programmer. the two 8- bit accumulators (a and b) can be used by some instructions as a single 16-bit accu- mulator called the d register, which allows a set of 16-bit operations even though the cpu is technically an 8-bit processor. the largest group of instructions added involve the y index register. twelve bit manip- ulation instructions that can operate on any memory or register location were added. the exchange d with x and exchange d with y instructions can be used to quickly get index values into the double accumulator (d) where 16-bit arithmetic can be used. two 16-bit by 16-bit divide instructions are also included.
m68hc11 general description motorola reference manual 1-3 figure 1-1 block diagram spi a/d converter sci port d control extal xtal e oscillator clock logic interrupt logic moda/ lir modb/ v stby timer system cpu cop pulse accumulator strobe and handshake port b pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 port c pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 strb stra pd5/ ss pd4/sck pd3/mosi pd2/miso pd1/txd pd0/rxd port e pe7/an7 pe6/an6 pe5/an5 pe4/an4 pe3/an3 pe2/an2 pe1/an1 pe0/an0 control port a pa7/pai/oc1 pa6/oc2/oc1 pa5/oc3/oc1 pa4/oc4/oc1 pa3/oc5/oc1 pa2/ic1 pa1/ic2 pa0/ic3 bus expansion parallel i/o address address/data r/ w as ss sck periodic interrupt mode control xirq irq/ reset mosi miso 256 bytes ram 512 bytes eeprom 8 kbytes rom v rl v rh v ss v dd txd rxd a15 a14 a13 a12 a11 a10 a9 a8 a7/d7 a6/d6 a5/d5 a4/d4 a3/d3 a2/d2 a1/d1 a0/d0 r/ w as single chip mode expanded mode circuitry enclosed by dotted line is equivalent to mc68hc24.
motorola general description m68hc11 1-4 reference manual figure 1-2 m68hc11 programmers model 1.3 product derivatives the m68hc11 family of mcus is composed of several members (see table 1-1 ), and new members are being developed. figure 1-3 explains how the product part num- bers are constructed. 8-bit accumulators a & b 70 70 15 0 ab d ix iy sp pc 70 c v z n i h x s or 16-bit double accumulator d index register x index register y stack pointer program counter carry/borrow from msb overflow zero negative i-interrupt mask half carry (from bit 3) x-interrupt mask stop disable condition codes
m68hc11 general description motorola reference manual 1-5 figure 1-3 part numbering hc11 part numbering mc 68 hc p 11xx b c fn 3 r2 mc fully specified and qualified numeric designator (optional) xc pilot production device pc engineering sample cop option (only on a-series devices) none p cop disabled cop enabled operating voltage range hc hcmos (v dd = 5.0 vdc 10%) hcmos (v dd = 3.0 vdc to 5.5 vdc) l base part number 11a8, 11d3, 11e9, 11k4, etc. monitor mask none b blank buffalo temperature range none c 0 c to 70 c C 40 c to 85 c C 40 c to 105 c v C 40 c to 125 c m package type fn fs 44/52/68/84-pin plcc 44/52/68/84-pin clcc 64/80-pin qfp fu maximum specified clock speed 2 2.0 mhz 3.0 mhz 3 4.0 mhz 4 memory type blank 7 masked rom or no rom eprom/otprom 8 eeprom 44-pin qfp fb 112-pin tqfp pv 80/100-pin tqfp pu 52-pin tqfp pb tape and reel option none r2 standard packaging tape and reel packaging 7 qualification level 40/48-pin dip p 48-pin sdip s
motorola general description m68hc11 1-6 reference manual 1.the eeprom is relocatable to the top of any 4 kbyte memory page. relocation is done with the upper four bits of the config register. 2. config register values in this table reflect the value programmed prior to shipment from motorola. 3. at the time of this printing a change was being considered that would make this value $0f. table 1-1 m68hc11 family members part number eprom rom ee- prom ram config 2 comments MC68HC11a8 512 256 $0f family built around this device MC68HC11a1 512 256 $0d a8 with rom disabled MC68HC11a0 256 $0c a8 with rom and eeprom disabled mc68hc811a 8 8k + 512 256 $0f eeprom emulator for a8 MC68HC11e9 12k 512 512 $0f four input capture/bigger ram 12k rom MC68HC11e1 512 512 $0d e9 with rom disabled MC68HC11e0 512 $0c e9 with rom and eeprom disabled mc68hc811e 2 2k 1 256 $ff 3 no rom part for expanded systems mc68hc711e 9 12k 512 512 $0f one-time programmable version of e9 MC68HC11d3 4k 192 n/a low-cost 40-pin version mc68hc711d 9 4k 192 n/a one-time programmable version of d3 MC68HC11f1 512 1 1k $ff 3 high-performance non-multiplexed 6b-pin MC68HC11k4 24k 640 768 $ff > 1 mbyte memory space, pwm, c s , 84-pin mc68hc711k 4 24k 640 768 $ff one-time programmable version of k4 MC68HC11l6 16k 512 512 $0f like e9 with more rom and more i/o, 64/ 68 mc68hc711l6 16k 512 512 $0f one-time programmable version of l4
m68hc11 pins and connections motorola reference manual 2-1 section 2 pins and connections this section discusses the functions of each pin on the MC68HC11a8. most pins on this microcontroller unit (mcu) serve two or more functions. information about the practical use of each pin is presented in these pin descriptions. this section also in- cludes information concerning pins that are exposed to illegal levels or conditions. the most common source of illegal levels or conditions is transient noise; however, a de- signer may wish to take precautions against potential misapplication of a product or failures of other system components such as power supplies. consideration of these factors can influence end-product reliability. the basic connections for single-chip-mode and expanded-mode applications are pre- sented in 2.5 typical single-chip-mode system connections and 2.6 typical ex- panded-mode-system connections . these basic systems can be used as the starting point for any user application and can minimize the time required to achieve a working prototype system. the explanation of these basic systems includes informa- tion concerning additions, such as additional memory on the expanded system. system noise generation and susceptibility primarily depend on each system and its environment. the MC68HC11a8 is designed for higher bus speeds than earlier mcus; since it is high-density complementary metal-oxide semiconductor (hcmos), signals drive from rail to rail, unlike earlier n-channel metal-oxide semiconductor (nmos) processors. since these factors can significantly affect noise issues, the sys- tem designer should consider these changes. 2.1 packages and pin names the following figures show pin assignments for several members of the m68hc11 mcu family. the pin assignments for the mc68hc24 port replacement unit (pru) are also presented for reference although the pru is not discussed in detail in this manual. detailed mechanical data for packages may be found in the data sheets or technical summaries. ordering information, which relates part number suffixes to package types and operating temperature range, are also found in the data sheets or technical sum- maries. 2.1.1 MC68HC11a8 the MC68HC11a8 is available in either a 52-pin plastic leaded chip carrier (plcc) package or a 48-pin dual-in-line package (dip). the silicon die is identical for both packages, but four of the analog-to-digital (a/d) converter inputs are not bonded out to pins in the 48-pin dip. the MC68HC11a1 and MC68HC11a0 devices also use the same die as the MC68HC11a8, except that the contents of the nonvolatile config register determine whether or not internal read-only memory (rom) and/or electrically
motorola pins and connections m68hc11 2-2 reference manual erasable programmable rom (eeprom) are disabled. these downgraded device versions have identical pin assignments as the MC68HC11a8. figure 2-1 shows the pin assignments for the MC68HC11a8 in the 52-pin plcc pack- age and the 48-pin dip package. figure 2-1 MC68HC11a8 pin assignments 2.1.2 MC68HC11d3/711d3 the MC68HC11d3 is available in either a 44-pin plcc package or a 40-pin dip pack- age. the silicon die is identical for both packages, but the plcc version has two ad- ditional output compare pins bonded out and an extra v ss pin named e vss . the mc68hc711d3 is functionally equivalent to the MC68HC11d3 but has 4 kbytes of eprom instead of mask programmed rom. the mc68hc711d3 is available as a one-time-programmable (otp) mcu in an opaque plastic package or in a ceramic windowed package for development applications. figure 2-2 shows the pin assignments for the MC68HC11d3/711d3 in the 44-pin plcc package and the 40-pin dip package. xtal pc0/a0/d0 pc1/a1/d1 pc2/a2/d2 pc3/a3/d3 pc4/a4/d4 pc5/a5/d5 pc6/a6/d6 pc7/a7/d7 reset xirq irq pd0/rxd pe4/an4 pe0/an0 pb0/a8 pb1/a9 pb2/a10 pb3/a11 pb4/a12 pb5/a13 pb6/a14 pb7/a15 pa0/ic3 extal strb/r/ w e stra/as moda/ lir modb/v stby v ss v rh v rl pe7/an7 pe3/an3 pd1/txd pd2/miso pd3/mosi pd4/sck pd5/ ss v dd pa7/pai/oc1 pa6/oc2/oc1 pa5/oc3/oc1 pa4/oc4/oc1 pa3/oc5/oc1 8 9 10 11 12 13 14 15 16 17 44 43 42 41 40 39 38 37 36 35 34 21 22 23 24 25 26 27 28 29 30 31 7 6 5 4 3 1 2 52 51 50 49 18 19 pa2/ic1 32 pa1/ic2 33 pe6/an6 48 pe2/an2 47 pe1/an1 45 pe5/an5 46 20 MC68HC11a8 pb7/a15 pb6/a14 pb5/a13 pb4/a12 pb3/a11 pb2/a10 pb1/a9 pb0/a8 pe0/an0 pe1/an1 9 10 11 12 13 14 15 16 17 18 pe2/an2 19 pe3/an3 20 21 v rh 22 v ss 23 modb/v stby 24 pa0/ic3 8 pa1/ic2 7 pa2/ic1 6 pa3/oc5/oc1 5 pa4/oc4/oc1 4 pa5/oc3/oc1 3 pa6/oc2/oc1 2 pa7/pai/oc1 1 pc7/a7/d7 pc6/a6/d6 pc5/a5/d5 pc4/a4/d4 pc3/a3/d3 pc2/a2/d2 pc1/a1/d1 pc0/a0/d0 xtal extal strb/r/ w 38 37 36 35 34 33 32 31 30 29 28 reset 39 xirq 40 e 27 stra/as 26 moda/ lir 25 irq 41 pd0/rxd 42 pd1/txd 43 pd2/miso 44 pd3/mosi 45 pd4/sck 46 pd5/ ss 47 v dd 48 v rl MC68HC11a8
m68hc11 pins and connections motorola reference manual 2-3 figure 2-2 MC68HC11d3/711d3 pin assignments 2.1.3 MC68HC11e9/711e9 the MC68HC11e9 is available in a 52-pin plcc package only. the MC68HC11e1 and MC68HC11e0 devices also use the same die as the MC68HC11e9, except that the contents of the nonvolatile config register determine whether or not internal rom and/or eeprom are disabled. these downgraded device versions have identi- cal pin assignments as the MC68HC11e9. the MC68HC11e9 is an upgrade of the MC68HC11a8. the MC68HC11e9 has 12 kbytes of mask rom, 512 bytes of eeprom, and 512 bytes of ram. the timer sys- tem allows one output-compare channel to be reconfigured as a fourth input-capture channel. the mc68hc711e9 is functionally equivalent to the MC68HC11e9 but has 12 kbytes of eprom instead of mask programmed rom. the mc68hc711e9 is available as a one-time programmable (otp) mcu in an opaque plastic package or in a ceramic win- dowed package for development applications. figure 2-3 shows the pin assignments for the MC68HC11e9 in the 52-pin plcc pack- ages. these pin assignments are the same as the MC68HC11a8, except for the pin name for the pa3/oc5/ic4/oc1 pin. pc4/addr4 pc5/addr5 pc6/addr6 pc7/addr7 xirq/v pp pd7/r/ w pd6/as reset irq pd0/rxd pd1/txd pb2/addr10 pb3/addr11 pb4/addr12 pb5/addr13 pb6/addr14 pb7/addr15 nc pa0/ic3 pa1/ic2 pc3/addr3 pc2/addr2 pc1/addr1 pc0/addr0 v ss ev ss xtal extal e moda/ lir modb/v stby pd2/miso pd3/mosi pd4/sck pd5/ ss v dd pa7/pa i /oc1 pa6/oc 2 /oc1 pa5/oc3/oc1 pa4/oc4/oc1 pa3/ic4/oc5/oc1 pa2/ic1 7 8 9 10 11 12 13 14 15 16 37 36 35 34 33 32 31 30 29 18 19 20 21 22 23 24 25 26 27 28 6 5 4 3 2 1 44 43 42 41 40 17 pb1/addr9 38 pb0/addr8 39 mc68hc(7)11d3 pc7/addr7 xirq/v pp pd7/r/ w pd6/as reset irq pd0/rxd pd1/txd pd2/miso pd3/mosi 9 10 11 12 13 14 15 16 17 18 pd4/sck 19 pd5/ ss 20 pc6/addr6 8 pc5/addr5 7 pc4/addr4 6 pc3/addr3 5 pc2/addr2 4 pc1/addr1 3 pc0/addr0 2 v ss 1 pb5/addr13 pb6/addr14 pb7/addr15 pa0/ic3 pa1/ic2 pa2/ic1 pa3/ic4/oc5/oc1 pa5/oc3/oc1 pa7/pai/oc1 v dd 30 29 28 27 26 25 24 23 22 21 pb4/addr12 31 pb3/addr11 32 pb2/addr10 33 pb1/addr9 34 pb0/addr8 35 modb/v stby 36 moda/ lir 37 e 38 extal 39 xtal 40 mc68hc(7)11d3
motorola pins and connections m68hc11 2-4 reference manual figure 2-3 MC68HC11e9/711e9 pin assignments (52-pin plcc) 2.1.4 mc68hc811e2 the mc68hc811e2 is very similar to the MC68HC11e9 version, except in the on-chip memory. the mc68hc811e2 includes 2 kbytes of eeprom, which can be remapped to the upper half of any 4 kbyte page in the 64 kbyte map. there is no masked rom memory in the mc68hc811e2. the mc68hc811e2 is available in either a 52-pin plcc package or a 48-pin dip. the silicon die used is the same for both packages, but four of the a/d converter inputs are not bonded out to pins in the 48-pin package. the mc68hc811e2 version replaces an earlier version called the mc68hc811a2. the only significant difference between the mc68hc811e2 and mc68hc811a2 is that the mc68hc811e2 has a slightly more flexible timer system, which allows one output-compare channel to be reconfigured as a fourth input-capture channel. the 52-pin plcc package version of the mc68hc811e2 has identical pin assign- ments to the MC68HC11e9 pin assignments shown in figure 2-3 . figure 2-4 illus- trates the pin assignments for the mc68hc811e2 in the 48-pin dip. xtal pc0/a0/d0 pc1/a1/d1 pc2/a2/d2 pc3/a3/d3 pc4/a4/d4 pc5/a5/d5 pc6/a6/d6 pc7/a7/d7 reset xirq irq pd0/rxd pe4/an4 pe0/an0 pb0/a8 pb1/a9 pb2/a10 pb3/a11 pb4/a12 pb5/a13 pb6/a14 pb7/a15 pa0/ic3 extal strb/r/ w e stra/as moda/ lir modb/v stby v ss v rh v rl pe7/an7 pe3/an3 pd1/txd pd2/miso pd3/mosi pd4/sck pd5/ ss v dd pa7/pai/oc1 pa6/oc2/oc1 pa5/oc3/oc1 pa4/oc4/oc1 pa3/oc5/oc1 8 9 10 11 12 13 14 15 16 17 44 43 42 41 40 39 38 37 36 35 34 21 22 23 24 25 26 27 28 29 30 31 7 6 5 4 3 1 2 52 51 50 49 18 19 pa2/ic1 32 pa1/ic2 33 pe6/an6 48 pe2/an2 47 pe1/an1 45 pe5/an5 46 20 MC68HC11e9
m68hc11 pins and connections motorola reference manual 2-5 figure 2-4 mc68hc811e2 pin assignments (48-pin dip) 2.1.5 MC68HC11f1 the MC68HC11f1 is available in a 68-pin plcc package only. the MC68HC11f1 is the first non-multiplexed address/data bus version of the m68hc11 family. in addition to the non-multiplexed bus, this mcu includes 1 kbyte of on-chip ram and intelligent chip selects for simple connection to external program memory without the need for any external logic chips. other on-chip peripherals are similar to the MC68HC11e9. figure 2-5 shows the pin assignments for the MC68HC11f1 in the 68-pin plcc pack- age. pb7/a15 pb6/a14 pb5/a13 pb4/a12 pb3/a11 pb2/a10 pb1/a9 pb0/a8 pe0/an0 pe1/an1 9 10 11 12 13 14 15 16 17 18 pe2/an2 19 pe3/an3 20 21 v rh 22 v ss 23 modb/v stby 24 pa0/ic3 8 pa1/ic2 7 pa2/ic1 6 pa3/oc5/oc1 5 pa4/oc4/oc1 4 pa5/oc3/oc1 3 pa6/oc2/oc1 2 pa7/pai/oc1 1 pc7/a7/d7 pc6/a6/d6 pc5/a5/d5 pc4/a4/d4 pc3/a3/d3 pc2/a2/d2 pc1/a1/d1 pc0/a0/d0 xtal extal strb/r/ w 38 37 36 35 34 33 32 31 30 29 28 reset 39 xirq 40 e 27 stra/as 26 moda/ lir 25 irq 41 pd0/rxd 42 pd1/txd 43 pd2/miso 44 pd3/mosi 45 pd4/sck 46 pd5/ ss 47 v dd 48 v rl mc68hc811e2
motorola pins and connections m68hc11 2-6 reference manual figure 2-5 MC68HC11f1 pin assignments (68-pin plcc) 2.1.6 mc68hc24 port replacement unit the mc68hc24 is available in either a 44-pin plcc package or a 40-pin dip. figure 2-6 shows the pin assignments for the mc68hc24 in the 44-pin plcc package and the 40-pin dip package. data1/pc1 data2/pc2 data3/pc3 data4/pc4 data5/pc5 data6/pc6 data7/pc7 reset xirq irq csprog/pg7 csgen/pg6 csio1/pg5 pf0/addr0 pf1/addr1 pf2/addr2 pf3/addr3 pf4/addr4 pf5/addr5 pf6/addr6 pf7/addr7 pb0/addr8 pb1/addr9 pb2/addr10 data0/pc0 4xout xtal extal r/ w e v ss v rh v rl moda/ lir pg0 rxd/pd0 txd/pd1 miso/pd2 mosi/pd3 sck/pd4 ss/pd5 v dd pai/oc1/pa7 oc2/oc1/pa6 oc3/oc1/pa5 10 11 12 13 14 15 16 17 18 19 58 57 56 55 54 53 52 51 50 49 48 27 28 29 30 31 32 33 34 35 36 37 9 8 7 6 5 1 4 2 68 67 20 21 oc4/oc1/pa4 38 oc5/oc1/pa3 39 pe7/an7 66 65 pe0/an0 59 pe4/an4 60 22 pe3/an3 pe6/an6 pe2/an2 64 63 pe5/an5 62 pe1/an2 61 ic1/pa2 ic2/pa1 40 41 ic3/pa0 42 addr15/pb7 43 3 csio2/pg4 pg3 pg2 pg1 pb3/addr11 pb4/addr12 pb5/addr13 pb6/addr14 23 47 46 45 44 24 25 26 modb/v stby MC68HC11f1
m68hc11 pins and connections motorola reference manual 2-7 figure 2-6 mc68hc24 pin assignments 2.2 pin descriptions this section provides a pin-by-pin description of the mcu. in general, a designer should consider all possible functions of each pin when designing the mcu into an ap- plication system. section 7 parallel input/output contains transistor-level schematics of the logic associated with each of the i/o pins. section 3 configu- ration and modes of operation discusses the pins that operate as a multi- plexed address/data bus in expanded modes of operation as well as the functions of other pins related to mode selection and bus control. the reset and interrupt pins are presented again in section 5 resets and interrupts . sections 8 through 12 discuss pins related to the on-chip peripherals presented in those sections. figure 2-1 is a pin-function-oriented block diagram of the MC68HC11a8, which is a good reference for development and verification of application designs. 2.2.1 power-supply pins (v dd and v ss ) power is supplied to the mcu by using these pins. v dd is the positive power input, and v ss is ground. the MC68HC11a8 mcu uses a single power supply, but in some ap- plications, there may also be optional power supplies for a/d reference and/or for bat- tery backup of on-chip random-access memory (ram). these additional power sources are optional, and the mcu, including ram and a/d, can operate from a single 5-v (nominal) power supply. stra pc0 pc1 pc2 pc3 nc pc4 pc5 pc6 pc7 v dd ad1 ad2 ad3 nc ad4 ad5 ad6 ad7 v ss a12 a13 a14 a15 i/o test nc cs mode as e r/ w strb pb7 pb6 pb5 pb4 nc pb3 pb2 pb1 pb0 irq 7 8 9 10 11 12 13 14 15 16 37 36 35 34 33 32 31 30 29 18 19 20 21 22 23 24 25 26 27 28 6 5 4 3 2 1 44 43 42 41 40 17 ad0 38 reset 39 mc68hc24 pc2 pc3 pc4 pc5 pc6 pc7 v dd strb pb7 pb6 9 10 11 12 13 14 15 16 17 18 pb5 19 pb4 20 pc1 8 pc0 7 stra 6 a12 5 a13 4 a14 3 a15 2 i/o test 1 ad4 ad5 ad6 ad7 v ss irq pb0 pb1 pb2 pb3 30 29 28 27 26 25 24 23 22 21 ad3 31 ad2 32 ad1 33 ad0 34 reset 35 r/ w 36 e 37 as 38 mode 39 cs 40 mc68hc24
motorola pins and connections m68hc11 2-8 reference manual although the MC68HC11a8 is a cmos device, very fast signal transitions are present on many of the pins. even when the mcu is operating at slow clock rates, short rise and fall times are present. depending upon the loading on these fast signals, signifi- cant short-duration current demands can be placed on the mcu power supply. special care must be taken to provide good power-supply bypassing at the mcu. the faster edge times in the MC68HC11a8 generally place greater demands on by- passing than earlier nmos mcu designs. a typical expanded-mode system should in- clude a 1- m f capacitor and a separate 0.01- m f capacitor. both these capacitors should be as close (physically and electrically) as possible to the MC68HC11a8 and should have good high-frequency characteristics (i.e., not old-technology dipped ce- ramic disc). the 1- m f capacitor primarily supplies charge for bus switching through a very low-impedance path (minimum-length runners). without this bypass, there could be very large voltage drops in the circuit board runners to the mcu due to the very high (although very short duration) current spike caused by several mcu pins simulta- neously switching from one level to the other. the separate 0.01- m f capacitor is in- cluded because the larger 1- m f capacitor is typically not as good at snubbing very high-frequency (low energy) noise. these are only general recommendations. some lightly loaded single-chip systems may work quite well with a single 0.1- m f bypass ca- pacitor; whereas, more heavily loaded expanded-mode systems may require more elaborate bypassing measures. it is easier and less expensive to approach power-supply layout and bypassing as a preventive measure from the beginning of a design than to locate and correct a noise problem in a marginal design. problems related to inadequate power-supply layout and bypassing are very difficult to locate and correct, but, if reasonable care is taken from the start of a design, noise should not arise as a problem. 2.2.2 mode select pins (modb/v stby and moda/ lir ) the mode b/standby ram supply (modb/v stby ) pin functions as both a mode select input pin and a standby power-supply pin. the mode a/load instruction register (mo- da/ lir) pin is used to select the mcu operating mode while the mcu is in reset, and it operates as a diagnostic output signal while the mcu is executing instructions. the hardware mode select mechanism starts with the logic levels on the moda and modb pins while the mcu is in the reset state. the logic levels on the moda and modb pins are fed into the mcu via a clocked pipeline path. the levels captured are those that were present part of a clock cycle before the reset pin rose, which as- sures there will be a zero hold-time requirement on the mode select pins relative to the rising edge at the reset pin. the captured levels determine the logic state of the spe- cial mode (smod) and mode a select (mda) control bits in the highest priority inter- rupt (hprio) register. these two control bits actually control the logic circuits involved in hardware mode selection. mode a selects between single-chip modes and expand- ed modes; mode b selects between the normal variation and the special variation of the chosen operating mode. bootstrap mode is the special variation of single-chip mode, and special test is the special variation of expanded mode. table 2-1 summa- rizes the operation of the mode pins and mode control bits.
m68hc11 pins and connections motorola reference manual 2-9 after reset is released, the mode select pins no longer influence the mcu operating mode. the moda pin serves the alternate function of load instruction register ( lir) when the mcu is not in reset. the open-drain active-low lir output pin drives low dur- ing the first e cycle of each instruction. the modb pin serves the alternate function of a standby power supply (v stby ) to maintain ram contents when v dd is not present. the power-saving mode, stop, is an alternate way to save ram contents, which does not require a separate standby power source. the lir function is intended for monitoring on a logic analyzer during debug of a sys- tem. since this status indicator shows where each instruction begins, programs can be followed easily. the mode a select levels and the lir status levels were selected to prevent interference between the shared functions of the pin. in single-chip applica- tions, this pin is simply connected to v ss . since the lir output is open-drain, there is no conflict between the direct v ss connection and the lir signal that drives the pin low during the first e cycle of each instruction. there is no practical reason to monitor lir during single-chip modes because there is no visibility to internal data and address buses. in expanded-mode systems, the moda/ lir pin is normally pulled up to v dd by a 4.7 k w resistor. during reset, the pull-up resistor instructs the moda pin to select expanded modes. during-program execution, the pin is driven low during the first cycle of each instruction by the lir signal and is pulled up between lir signals by the ex- ternal 4.7 k w pull-up. in expanded-mode systems where it is important to minimize power-supply current, logic could be used to drive the moda/ lir pin rather than just using a simple pull-up (see figure 2-7 ). during reset, the moda pin would be driven high to select expanded mode. after reset, the lir pin would be driven low by logic. the logic should not be operating against a pull-up, but rather it should be a logic-gate-type output with some series resistance to protect against the unlikely event of a conflict between an active- low lir signal and an active-high logic-gate output signal. such a conflict could only occur briefly at the falling edge of reset. since lir is active for about one out of every three cycles during normal execution (average instructions take about three cycles), i dd could be reduced by about 350 m a (5 v ? 4.7 k w x 33% duty cycle). table 2-1 hardware mode select summary inputs mode description control bits in hprio (latched at reset) modb moda rboot smod mda irv 1 0 normal single chip 0000 1 1 normal expanded 0010 0 0 special bootstrap 1101 0 1 special test 0111
motorola pins and connections m68hc11 2-10 reference manual figure 2-7 reduced i dd moda/ lir connections the v stby function is accomplished by a transistor switch that connects either v stby or v dd to the ram and reset logic, depending upon the relative levels of v stby and v dd . the switch connects v dd unless v stby is more than a threshold higher than v dd . a threshold is approximately a diode drop (0.7 v) but varies from lot to lot due to pro- cessing variations. during normal operation of the mcu, v dd is supplying power to the ram. in a standby situation, v stby should be maintained at a valid level, and reset should be activated (pulled low) when v dd drops below legal limits. reset should al- ways be held low whenever v dd is below its operating limit. if the mcu is to be oper- ated in a special mode (modb low before applying reset) and the modb/v stby pin is being used to back up the ram, the modb/v stby pin should not be driven low unless v dd is at (has returned to) a legal level. some logic may be required in systems that use modb/v stby as a standby supply and wish to use one of the special modes of operation. in most applications, the modb pin would be connected to v dd through a 4.7 k w pull-up resistor for normal modes or directly to ground for special modes. there are two ways to maintain the contents of on-chip ram with minimal power con- sumption (as in a battery-based application). the preferred method uses the stop mode of operation, and the second method uses the modb/v stby pin (see figure 2- 8 ). each of these methods has advantages. the stop method is preferred because it is much simpler than the separate power-supply method in terms of hardware costs and complexity. the stop method saves power by stopping all mcu clocks, which reduces the v dd current to a few microamps. no external logic is needed, and the con- tents of internal registers are maintained in addition to the contents of internal ram. the modb/v stby pin method would be used in cases where there is a significant amount of external circuitry operating from v dd so that the added complexity of two supplies and added logic is justified by the power savings. 4.7k reset 74hc04 to moda/ lir of m68hc11
m68hc11 pins and connections motorola reference manual 2-11 figure 2-8 ram standby modb/v stby connections 2.2.3 crystal oscillator and clock pins (extal, xtal, and e) the oscillator pins can be used with an external crystal network or an externally gen- erated cmos-compatible clock source. the frequency applied to these pins is four times higher than the desired bus frequency (e-clock rate). the e clock is the bus fre- quency clock output, which is used as a basic timing reference signal. when the e clock is low (address portion of a bus cycle), an internal process is occurring; when e is high, data is being addressed. the e clock is free running at one-fourth the crystal frequency as long as the oscillator is active (stop stops all clocks). the oscillator in the MC68HC11a8 consists of a large two-input nand gate. one of the inputs to this gate is driven by an internal signal that disables the oscillator when the mcu is in the stop mode. the other input is the extal input pin of the mcu. the output of this nand gate is the xtal output pin of the mcu. the xtal pin is normally left unterminated when using an external cmos-compatible clock input to the extal pin. however, a 10 k w -100 k w load resistor to ground may be used to reduce generated radio frequency interference (rfi) noise emission. the xtal output is normally intended to drive only a crystal, but xtal can be used as a 4 x clock output if special care is taken to avoid undesirable loading. the xtal output may be buffered with a high-impedance buffer such as the 74hc04, or it may be used to drive the extal input of another m68hc11 mcu. in all cases, the circuit-board lay- out around the oscillator pins is critical. load capacitances specified in the data sheets and technical summary include all stray layout capacitances. thus, the physical ca- pacitors connected to these pins should always be less than the specified load capac- itances by the estimated interconnection capacitances. figure 2-9 and figure 2-10 show the internal and external components that form the crystal oscillator, called a pierce oscillator (also known as a parallel resonant crystal oscillator). figure 2-9 shows the connections for high-frequency crystals (greater than 1 mhz), and figure 2-10 shows connections for low-frequency operation (less than 1 mhz). out 4.7k to modb/v stby max 690 v v batt v dd + 4.8 v nicd of m68hc11 v dd
motorola pins and connections m68hc11 2-12 reference manual the resistor, r f , provides a direct current bias to the input so the nand operates in its linear region. in low-frequency designs, r s and c2 provide a phase shift. r s also limits the power into the crystal, which is important for many small crystals because they are designed for very low drive levels (typically 1- m w maximum). in high-frequency appli- cations (see figure 2-9 ), the output impedance of the nand driver, combined with the lower impedance of c1 and c2, provides the same effect as the r s in low-frequency designs. higher frequency at-cut crystals are designed for much higher drive levels. figure 2-9 high-frequency crystal connections figure 2-10 low-frequency crystal connections exact values for the external components are a function of wafer processing parame- ters, package capacitance, printed circuit board (pcb) capacitance and inductance, m68hc11 xtal extal r f c2 c1 xtal stop m68hc11 xtal extal r f c2 c1 xtal stop r s
m68hc11 pins and connections motorola reference manual 2-13 socket capacitance, operating voltage, crystal technology, and frequency. typical val- ues are as follows: a tune-up procedure for experimentally determining r s will be discussed at the con- clusion of this subsection. since circuit and layout capacitances effectively add to the values of c1 and c2, the physical capacitances are usually smaller than the intended capacitances. in most high-frequency applications, the values of c1 and c2 are equal. in low-fre- quency designs, it is often desirable to make c1 smaller than c2, which provides a higher voltage at the extal input due to an impedance transformation. the wider volt- age swing at this input will result in lower power-supply current. as in all crystal oscillator designs, all leads should be kept as short as possible. it is also good practice to route v ss paths as shown in figure 2-11 . these paths isolate the oscillator input from the output and the oscillator from adjacent circuitry, only add- ing capacitance in parallel with c1 and c2. potentially noisy lines should be kept as far as possible from the oscillator components. ground loops should be avoided around oscillator components (note the unterminated v ss paths ending under c1 and c2 in figure 2-11 ). figure 2-11 crystal layout example r f = 1 m w C20 m w higher values are sensitive to humidity; lower values reduce gain and could prevent startup. cl = 5 pfC25 pf value is usually fixed. c2 = 5 pfC25 pf value may be varied to trim frequency. crystal c1 c2 r f pin 7 extal pin 8 xtal m68hc11 mcu
motorola pins and connections m68hc11 2-14 reference manual usually, the operation of the oscillator cannot be observed with an oscilloscope con- nected to one of the oscillator pins. the oscilloscope adds from 3 to 30 pf and from 1 to 10 m w to v ss , which will usually affect oscillator operation. when the oscilloscope is connected to the extal input, the 10 m w to v ss (oscilloscope input) forms a resis- tive divider with r f and often disables the oscillator by biasing the circuit out of the lin- ear region of the extal input. this problem can sometimes be overcome by capacitively coupling the oscilloscope with a very small capacitor (1C5 pf) between the oscilloscope probe and the oscillator pin. it is usually better to observe the e-clock output from the mcu since this does not alter the operation of the oscillator. in low-frequency designs, it is often possible to observe the xtal node with an oscil- loscope because the high-impedance nodes of the oscillator are isolated from xtal by r s . observe i dd without the oscilloscope connected and again with the oscillo- scope connected. if the i dd is unchanged, it is usually safe to assume the oscillator was unaffected. low-frequency crystal circuits tend to be very high impedance. thus, the pcb must be clean, dry, and free of conductive material such as solder rosin and excessive mois- ture from high humidity. if problems occur, the value of r f can be reduced so the con- taminant impedance is less significant in comparison. of course, it is still best to eliminate the contaminants. usually, startup time is inversely proportional to the frequency; thus, low-frequency os- cillators start slower than high-frequency oscillators. there are many exceptions to this rule because there are many variables affecting startup time. observation of a few cir- cuits using the MC68HC11a8 with an 8-mhz crystal reveals startup from stop takes approximately two milliseconds, and startup from power-up occurs within a few milli- seconds of when v dd reaches approximately one volt. power-up performance varies greatly since power-source turn-on characteristics vary greatly. since the MC68HC11a8 is a fully static design, the oscillator is not required to be running full speed before the processor starts executing instructions (most applications do not re- quire a stable oscillator within the first few milliseconds after power-up). if the oscillator is not running at full speed, instructions will take longer to execute, but no unpredict- able behavior will result as it would in an nmos processor. an oscillator in the 32-khz range could require hundreds of milliseconds or even a few seconds to start and sta- bilize. note the following tune-up procedure is only meaningful for crystal fre- quencies below 1 mhz. in higher frequency applications, because r s is normally 0 w , this procedure is not needed. the value of r s can be determined experimentally by using the final pcb and an mcu of the exact type that will be used in the final application. the mcu need not have the final mask program because the mcu will be held in reset throughout the experiment. because of the number of variables involved, use components with the exact proper- ties of those that will be used in production. for example, do not use a ceramic-pack- aged mcu prototype for the experiment when a plastic-packaged mcu will be used in
m68hc11 pins and connections motorola reference manual 2-15 production. an emulator version of the part will also have slightly different electrical properties than the masked rom version of the same part. to determine the optimum value for r s , observe the operating current (i dd )ofthe mcu as a function of r s . the mcu should be held in reset throughout this procedure because operating current variations during run modes are much greater than the cur- rent variations due to varying r s . normally, a dip in current will occur. this dip is not sharp as in many lc circuits but is instead very broad. as the shape of this curve sug- gests, the exact value of r s is not critical. finally, verify that the maximum-operating supply voltage does not overdrive the crys- tal. observe the output frequency as a function of v dd at the buffered e-clock output. under proper operating conditions, the frequency should increase a few parts per mil- lion as supply voltage increases. if the crystal is overdriven, an increase in supply volt- age will cause a decrease in frequency, or the frequency will become unstable. if frequency problems arise, supply voltage must be decreased, or the values of r s , c1, and c2 should be increased to reduce the crystal drive. 2.2.4 crystal oscillator application information some crystal oscillator application information is presented in the following para- graphs. 2.2.4.1 crystals for parallel resonance parallel resonance refers to a pierce oscillator that has the crystal in parallel with an inverter. almost all (if not all) cmos mcus use this type oscillator. at-cut crystals are available as standard devices for both series resonant circuits and pierce oscillators. the load capacitance has to be specified for the pierce version. the series resonant versions do not require this specification and are more likely to be listed as a standard product. the type circuit affects the oscillating frequency of the crystal. any 4- to 8-mhz at-cut crystal will normally meet the requirements of an m68hc11. however, for a very accurate oscillator frequency, use the pierce version of the crystal with c1 and c2 values to match the specified load capacitance value for the crystal. the load capacitance is approximately equal to the series combination of c1 and c2. 2.2.4.2 using crystal oscillator outputs the crystal oscillator is actually an rf application. connecting the crystal pins to other circuitry is likely to interfere with proper operation of the oscillator. modern cmos in- puts are very high impedance and relatively low capacitance; thus, one of these inputs can be connected to the oscillator without disturbing the oscillator. the data sheet shows examples of ways the crystal oscillator can be used to drive other circuits for crystal frequencies between 4 and 8 mhz. 2.2.4.3 using external oscillator an externally built pierce oscillator will operate like a crystal connected to the m68hc11. use a single inverter and connect the crystal feedback resistor and load
motorola pins and connections m68hc11 2-16 reference manual capacitors as if the external inverter input were the extal pin and the inverter output were the xtal pin. use a 74hcu04 for this inverter. this device is an unbuffered hc- mos hex inverter. avoid schmitt-trigger devices because the oscillator may fail to start. buffer the output of the external pierce oscillator to drive additional logic. 2.2.4.4 at-strip vs at-cut crystals the at-strip is a new-technology low-power crystal. connecting one of these crystals to the m68hc11 may cause problems due to the nand gate in the mcu overdriving the crystal. use an at-cut crystal with the m68hc11 to avoid this problem. 2.2.5 reset pin ( reset) this active-low, bidirectional control signal is used as an input to initialize the MC68HC11a8 to a known startup state and as an open-drain output to indicate that an internal failure has been detected in either the clock monitor or computer operating properly (cop) watchdog circuit. this reset signal is significantly different from the reset signal used on earlier mcus. more detailed information about this pin can be found in section 5 resets and interrupts . the reset circuitry is specifically designed to work with lower levels of v dd than other mcu circuitry. thus, reset can be used to prevent undesirable performance as v dd power is applied or decays, which is important for applications in which the contents of on-chip ram must be maintained in the absence of v dd . in this situation, the ram and reset input logic in the mcu would be powered from a standby power source con- nected to the modb/v stby pin whenever v dd is too low to support proper mcu oper- ation. secondly, reset must be controlled when v dd is below legal operating limits to prevent unintentional corruption of eeprom data. even if an application is not us- ing the 512-byte eeprom, the config register is still an eeprom byte and must be protected from corruption. virtually all MC68HC11a8 systems should include automatic control of reset to drive it low whenever v dd is below legal limits. a simple, inexpensive, low voltage in- hibit (lvi) device such as the mc34064 or mc34164 can be used. the mc34064 is available in to-92 or sot-8 plastic packages and provides an open-drain output to directly drive the reset pin of the MC68HC11a8. this device is connected to v dd , v ss , and the reset pin of the mcu. a pull-up resistor from reset to v dd is the only other component required for the reset circuit in most applications. figure 2-12 shows a typical reset circuit.
m68hc11 pins and connections motorola reference manual 2-17 figure 2-12 reset circuit example 2.2.6 interrupt pins ( xirq, irq) the xirq pin provides a means for requesting non-maskable interrupts after reset ini- tialization. during reset, the x bit in the condition code register (ccr) is set, and any interrupts are masked until mcu software enables them. since the xirq input is level sensitive, it can be connected to a multiple-source wired-or network with an external pull-up resistor. xirq is often used as a power loss detect interrupt. the irq input provides a means for requesting asynchronous interrupts to the MC68HC11a8. irq is program selectable (option register), having a choice of ei- ther level-sensitive or falling-edge-sensitive triggering. after reset, irq is configured for level-sensitive operation by default. whenever xirq or irq are used with multiple interrupt sources ( irq must be config- ured for level-sensitive operation if there is more than one source of irq interrupt), each source must drive the interrupt input with an open-drain-type driver to avoid con- tention between outputs. there should be a single pull-up resistor near the mcu inter- rupt input pin (typically 4.7 k w ). there must also be an interlock mechanism at each interrupt source so that the source holds the interrupt line low until the mcu recogniz- es and acknowledges the interrupt request. if one or more other interrupt sources are still pending after the mcu services a request, the interrupt line will still be low; thus, the mcu will be interrupted again as soon as the interrupt mask bit in the mcu be- comes clear (normally upon return from an interrupt). the irq pin is used during factory testing as a bulk v pp programming voltage source, which allows for parallel programming of as many as half of the bytes in the eeprom in a single programming operation. since the on-chip charge pump does not have suf- ficient drive capability to simultaneously program this many eeprom locations, the external 20-v power supply is needed to supplement the on-chip charge pump. the 4.7 k w 3 1 2 3 1 2 [3] to reset v dd mc34064 reset gnd in of m68hc11 reset gnd in manual reset switch 4.7 k w 1.0 m f mc34164 4.7 k w v dd v dd
motorola pins and connections m68hc11 2-18 reference manual switchover mechanism, which decides whether eeprom is powered by the internal charge pump or the external voltage source, is similar to the v stby logic at the modb/ v stby pin. when the external voltage is more than the charge-pump voltage, the switch connects the external high-voltage source to the internal v pp line. the added circuitry at this pin has no effect on normal irq functions, but it does have some effect on the way the pin reacts to illegal levels. in addition to xirq and irq, five other pins on the MC68HC11a8 can also be used to generate interrupt requests to the mcu. these pins are associated with other on-chip peripherals such as the timer or handshake i/o systems. the pins are pa0/ic3, pa1/ ic2, pa2/lc1, pa7/pai/oc1, and as/stra. the input-capture pins can be configured to detect rising edges, falling edges, or any edge. the pai and stra inputs can be configured to detect rising edges or falling edges. the stra input is only available if the mcu is operating in a single-chip mode because the pin is used as the address strobe (as) output when the mcu is in expanded modes. these five pins have advan- tages over the irq and xirq pins in that each of these five interrupts is independently maskable with a local control bit as well as the global i bit in the ccr. each of these five interrupts also has a readable status indication, and a pending request can be cleared without being serviced. 2.2.7 a/d reference and port e pins (v refl , v refh , pe[7:0]) the v refh and v refl pins provide the reference voltages for the a/d converter cir- cuitry. since the a/d converter is an all-capacitive charge-redistribution converter, there is essentially no dc current associated with these pins. very small dynamic cur- rents are caused by charge-redistribution switching during conversions (see sec- tion 12 analog-to-digital converter system ). these pins are normally connected to v dd and v ss through a low-pass filter network (see figure 2-13 ) to iso- late noise on the logic power supply from the relatively sensitive analog measure- ments. a low-noise precision reference supply can alternatively be used. there should be at least 2.5 v between v refl and v refh for full a/d accuracy. lower values will result in more inaccuracy, but the converter will continue to operate. the a/d system is tested at 4.5 v and 5.5 v across the reference supply pins. there is an inherent diode from v refl to v ss .ifv refl goes below v ss by more than this diode drop, any conversion in progress may be corrupted, but no permanent phys- ical damage will result until significant current is drawn. the only documented cases of damage have been caused by blatant misapplication, such as connecting C12 v di- rectly to the v refl pin. since no p-channel devices are associated with the v refh pin, there is no diode clamping to v dd . the gates of analog switches associated with the a/d reference and input pins are controlled by signals that switch between v ss and about 7 v. this higher-than-v dd supply is the output of a charge pump (separate from the charge pump used for programming on-chip eeprom). there is no special re- quirement to keep v refh below v dd . in fact, the converter will continue to produce good results up to approximately 6 v on v refh .
m68hc11 pins and connections motorola reference manual 2-19 figure 2-13 low-pass filter for a/d reference pins the port e input pins are used for general-purpose inputs and/or a/d analog inputs. these inputs are designed so that the digital input buffers are disabled at all times ex- cept for part of a cycle during an actual read of port e; thus, analog levels near the switch point of the digital input buffer do not result in high power-supply current drains as in a normal cmos input buffer. the buffers are enabled by an extra n-channel de- vice in series with the n-channel device in the input inverter. during a digital read of port e, these extra n-channel devices are turned on for part of the read cycle. because of this special circuitry, it is not necessary to terminate unused port e pins. the analog and digital functions of port e do not normally interfere with each other; thus, any combination of pins can be used as digital inputs while the remaining port e pins are used for analog inputs. turning on the digital buffer during an analog sample may cause small disturbances on the input line, which may cause small errors in the sampled analog level. the disturbances would be caused by small gate-to-drain and gate-to-source capacitances and would have to occur very close to the trailing edge of a sample period to have any noticeable effect. the disturbances are so small (if they exist) that they probably would not cause any measurable inaccuracy. since it is so easy to arrange software to avoid this condition, it is probably easier to avoid potential disturbances. 2.2.8 timer port a pins port a includes three input-only pins, four output-only pins, and one pin that can be configured to operate as an input or as an output. the input-only pins (pa0/ic3, pa1/ ic2, and pa2/lc1) also serve as edge-sensitive timer input-capture pins. the four out- put-only pins (pa3/oc5/oc1, pa4/oc4/oc1, pa5/oc3/oc1, and pa6/oc2/oc1) also serve as main timer output-compare pins. whenever an output-compare function is enabled, that pin cannot be used for general-purpose output. these four pins can be controlled by output compare 1 (oc1) and/or another output compare. the pa7/ pai/oc1 pin can be used as a general-purpose i/o pin, as a pulse-accumulator input, or as an oc1 output pin. 2.2.9 serial port d pins port d includes six general-purpose, bidirectional i/o pins that can be individually con- figured as inputs or as outputs. when the serial communications interface (sci) re- 1k 1 m f v dd to v refh of m68hc11 to v refl of m68hc11
motorola pins and connections m68hc11 2-20 reference manual ceiver is enabled, the pd0/rxd pin becomes an input dedicated to the rxd function. when the sci transmitter is enabled, the pd1/txd pin becomes an output dedicated to the txd function. when the serial peripheral interface (spi) system is enabled, the pd2/miso, pd3/mosi, pd4/sck, and pd5/ ss pins become dedicated to spi func- tions. even while the spi system is enabled, the pd5/ ss pin can be used as a general- purpose output by setting the corresponding ddrd5 bit, provided the spi system is configured for master mode of operation. the six port d pins can be configured (port d wired-or mode (dwom) control bit in spi control register (spcr)) for wired-or operation. this option disables the p-chan- nel device in the output drivers so port d outputs can actively drive low but not high, allowing two or more such outputs to be connected without contention. since the p- channel device is physically present (just turned off), there is an inherent diode from the output pin to v dd so the pin cannot be pulled to a level higher than v dd (unlike a transistor-transistor logic (ttl) open-collector output). an external pull-up resistor is required on all port d outputs when the wired-or option is used. the firmware boot- loader program configures port d for wired-or operation when the mcu is reset in bootstrap mode. if the application is using bootstrap mode, either turn off the wired- or option after downloading or supply external pull-up resistors on port d output pins. 2.2.10 ports b and c, stra, and strb pins these 18 pins are used for general-purpose i/o while the mcu is operating in single- chip mode. when an expanded mode is used, these 18 pins become a multiplexed ad- dress/data bus with an address strobe (as) and a read/write (r/ w) control line. table 2-2 summarizes the functions of these pins related to the mcu operating mode. in single-chip modes, no external address/data bus is needed; thus, these 18 pins are available for general-purpose i/o. port b is an 8-bit output-only port; port c is an 8-bit bidirectional i/o port. any combination of bits in port c can be configured as outputs; the remaining bits are used as inputs. several automated handshake i/o functions are associated with ports b and c. these strobe and handshake functions use the stra and strb pins as strobes and handshake controls. the stra pin is an edge-detect- ing input that causes port c data to be latched into a special internal latch register. the active edge for stra is software selectable, and any port c pin can be used for gen- eral-purpose static i/o while other pins are being used for latched inputs. if strobe and handshake functions are not being used, stra can still be used as an edge-detecting interrupt input but cannot be used as a general-purpose static input. the strb pin is an output strobe associated with the handshake i/o functions of ports b and c. if hand- shake functions are not being used, strb can still be used as a general-purpose out- put, though it is more difficult to control than a normal port output pin. for a detailed discussion of the handshake i/o functions of ports b and c, refer to section 7 par- allel input/output . when the mcu is operating in expanded modes, these 18 pins are used for an ad- dress/data bus to allow the central processing unit (cpu) to access a 64-kbyte mem- ory space. to save pins, the low-order address and 8-bit data are time multiplexed on eight pins. during the first half of each bus cycle, address output signals, addr[7:0], are present on these eight pins; during the second half of each bus cycle, these eight
m68hc11 pins and connections motorola reference manual 2-21 pins are used as a bidirectional data bus. the as signal is used as an active-high latch enable to an external address latch. address information is allowed through this exter- nal transparent latch while as is high, and the stable address information is latched when as is low. the e clock is used to enable external devices to drive data into the cpu during the second half of a read bus cycle (e clock high). the r/ w signal indi- cates the direction of data high for read cycles, low for write cycles. note the as/stra pin is an output in expanded modes and an input in single-chip modes. do not forget to terminate this pin as an unused input in single-chip modes. 2.3 termination of unused pins because the MC68HC11a8 is a cmos device, unused input pins must be terminated to assure proper operation and reliability. figure 2-14 shows a cmos inverter, which is representative of circuitry found on cmos input pins. when the input is logic zero, the p-channel transistor is on (conducting), and the n-channel transistor is off. when the input is logic one, the p-channel transistor is off, and the n-channel transistor is on. these transistors are actually linear devices with relatively broad switch points. as the input passes through midsupply, there is a region where both transistors conduct to some degree. under normal circumstances, the input does not remain in this linear region for very long. once the inverter has completely switched so that only one of the two transistors is conducting, there is virtually no current flow. this principle is why the overall current drain of a cmos device is directly proportional to the rate of switching. table 2-2 ports b and c, stra, and strb pins port bit single-chip and bootstrap mode expanded-multiplexed and special test mode b 0 pb0 output addr8 address output b 1 pb1 output addr9 address output b 2 pb2 output addr10 address output b 3 pb3 output addr11 address output b 4 pb4 output addr12 address output b 5 pb5 output addr13 address output b 6 pb6 output addr14 address output b 7 pb7 output addr15 address output c 0 pc0 input/output ad0 address/data multiplexed c 1 pc1 input/output ad1 address/data multiplexed c 2 pc2 input/output ad2 address/data multiplexed c 3 pc3 input/output ad3 address/data multiplexed c 4 pc4 input/output ad4 address/data multiplexed c 5 pc5 input/output ad5 address/data multiplexed c 6 pc6 input/output ad6 address/data multiplexed c 7 pc7 input/output ad7 address/data multiplexed stra input strobe (edge in) as address strobe (out) strb output strobe r/w read/write select
motorola pins and connections m68hc11 2-22 reference manual essentially all current is due to gates that are in the linear region during transitions and for charging and discharging internal capacitances. because the input is very high im- pedance, if it is not connected, the input can oscillate or float to a midsupply level. ei- ther of these conditions can result in added power-supply current. the oscillation case can result in coupling of noise to the power supply. in older cmos designs, the large currents caused by an input that floated to midsupply could even induce cmos latch- up, which could destroy the integrated circuit. current design techniques on the MC68HC11a8 have made latchup due to a floating input unlikely, but it is still impor- tant to terminate unused inputs to avoid oscillation, noise, and added supply current. some inputs on the mcu ( reset, extal, moda, and modb) cannot be left unter- minated in any system. figure 2-14 cmos inverter the port e input pins have an extra n-channel device between v ss and the bottom of the n-channel device of the input inverter. since this extra device is only enabled for half a cycle during a digital read of port e, it is less important to terminate unused port e pins than other unused inputs. in cases of very slow bus frequencies, even half a cycle might be a significant length of time, and unused port e pins could be terminated. in some battery-powered systems where port e is read often, it would be desirable to eliminate the potential added supply current. since the v refl and v refh pins do not connect to the inputs of any cmos gates with- in the MC68HC11a8, these pins do not need terminating if they are not used. although termination is not required, it may reduce the risk of damage due to high-voltage static electricity. other than a/d pins, there are two basic types of input pins on the MC68HC11a8 an input-only pin and an input/output pin. the best method to terminate unused inputs is with a pull-up or pulldown resistor for each unused pin. input-only pins can be con- nected to each other and then to a common termination point. although this method is less expensive and takes less space than individual pull-ups, it is much harder to sep- arate and use one of these pins if it is needed later. although input-only pins can be connected directly to v dd or v ss , it is better not to because this connection makes it difficult to change the level at that input. if a pull-up or pulldown resistor is used in- stead, a signal can easily be connected to the input later. the preferred method of ter- out v dd p n in
m68hc11 pins and connections motorola reference manual 2-23 minating pins that can be configured for input or output is with individual pull-up or pulldown resistors for each unused pin. some users leave these pins unconnected and reconfigure them as outputs during initialization. there is still a brief period during reset and initialization where these pins are unterminated inputs. there is also a small risk that a defective system might fail to reconfigure these pins as outputs. a pin ca- pable of being configured as an output should never be connected to another such pin or directly to either power-supply rail. if the pin ever became an output, there is a pos- sibility of high current drain due to an output conflict. part of the verification procedure for the design of every mcu system should be a pin- by-pin review of what is connected to every pin on the mcu to eliminate potential prob- lems. 2.4 avoidance of pin damage any integrated circuit can be damaged or destroyed by exposure to illegal voltages or conditions. by understanding the failure mechanisms, a designer can protect against damaging conditions. in some cases, a product can even be designed to tolerate com- mon end-user errors by designing protective interface circuits. the data sheets for integrated circuits state conservative limits and conditions that will definitely protect the integrated circuit. the consequences of violating the specified limits are not usually discussed because there are too many variables affecting the re- sults. in some cases, the mcu can tolerate significantly worse conditions than the stat- ed limits, although it is almost impossible to quantify or guarantee this better performance for all parts and conditions. there are several basic types of pin interface circuits on the MC68HC11a8. the exact devices connected to the pin influence what happens as the voltage level at the pin is driven above v dd or below v ss . many other factors, including ambient temperature and lot-to-lot process variations, also influence the reaction of the mcu to illegal volt- age levels and conditions. the following discussion explains the conditions leading to actual damage and what that damage might be. this information should be used as a guideline to help engineers avoid conditions leading to possible mcu damage. connected to the substrate of the silicon die, the v ss pin is the reference point from which all other voltages are measured. the v dd pin is the main positive power supply for the mcu. data sheet information is tested and guaranteed for v dd equal to 5 v 10 percent, but, in limited temperature range applications, the mcu can operate over a wider range of v dd (some timing and drive capability specifications may not be met). v dd and operating temperature have a significant effect on the speed of cmos logic. as v dd is reduced, the maximum crystal frequency must also be reduced. for v dd equal 5 v 10 percent, the MC68HC11a8 can operate with a maximum bus frequency of 2.1 mhz; when v dd is 3 v, the maximum bus frequency is about 1 mhz. at low tem- peratures, speed increases and power-supply current decreases. the mcu can typi- cally operate with v dd levels up to 7 v without damaging the mcu, but timing and drive levels will differ from the specified limits. also, there may be some adverse effects on gate oxides from long-term exposure to v dd greater than or equal to 7 v. a battery- based application could be exposed to v dd greater tha n 5 v when batteries are new
motorola pins and connections m68hc11 2-24 reference manual and still be expected to work properly as the battery voltage slowly decays to some level well below 5 v. although the MC68HC11a8 could be used in such an application, published specifications do not cover this range of v dd . 2.4.1 zap and latchup zap and latchup are terms familiar to failure analysis engineers that work on cmos integrated circuits. zap refers to damage caused by very high-voltage static-electricity exposure. static-electricity (zap) damage usually appears as breakdown of the rela- tively thin oxide layers that causes leakage or shorts. often secondary damage occurs after an initial zap failure causes a short. latchup refers to a usually catastrophic condition caused by turning on an unintention- al, bipolar, silicon-controlled rectifier (scr). a latchup scr is formed by n and p re- gions in the layout of the integrated circuit, which act as the collector, base, and emitters of unintentional, parasitic transistors. bulk resistance of silicon in the wells and substrate act as resistors in the scr circuit. application of voltages above v dd or below v ss , in conjunction with enough current to develop voltage drops across the parasitic resistors in the unintentional scr circuit, can cause the scr to turn on. once this scr is turned on, it can normally only be turned off by removing all power from the integrated circuit. the on-impedance of the scr can overheat and destroy the in- tegrated circuit. improvements in layout and processing techniques have made newer hcmos devic- es, such as the MC68HC11a8, much less likely to suffer damage from zap and latch- up. because of the destructive nature of these mechanisms, it is impossible to test every device for zap and latchup limits the way timing and drive levels are tested. to assure product reliability, sample groups of devices are destructively tested. 2.4.2 protective interface circuits in applications where mcu pins might be exposed to detrimental conditions, protective interfaces may be needed to protect the mcu from damage. the two main goals of any protective interface are to prevent high currents from flowing and to prevent illegal voltage levels at a pin. a low-pass filter can often satisfy both goals. in less common situations, it may also be necessary to provide diode clamps to prevent high voltages at some pins. all pins on the m68hc11 have internal inherent diode clamps to v ss , but only some of the pins include clamps to v dd . the following subsections discuss the internal circuits for each type mcu pin and note special considerations for the pro- tection of these pin types. usually, the only pins needing protection are those that are exposed to signals from outside the system. for example, in an automobile engine controller, the sensors for air and fuel flow are connected to the engine control module and ultimately to mcu inputs. these signals are prime candidates for protective interfaces because noise or illegal levels could accidentally be applied through the interface wiring. on the other hand, any buses and signals wholly contained within the control module probably do not require any sort of protective interface because there is little chance that these sig- nals would be exposed to illegal levels. in a few cases, a protective interface can even
m68hc11 pins and connections motorola reference manual 2-25 interfere with normal operation of an mcu signal. for example, a low-pass filter on an address or data line of an expanded mcu system would introduce significant delays to these signals, dramatically limiting the maximum operating speed of the system. 2.4.3 internal circuitry digital input-only pin figure 2-15 shows the mos circuitry for a digital input-only pin. the gates of input buffer [3] are very high impedance for all voltages that would ever be applied to the pin. the thick-field protection device [2] normally prevents the pin voltage from reach- ing levels that could damage the gates of the input buffer. the exact circuitry of the input buffer may be different for different digital inputs (e.g., to provide hysteresis, etc.), but only device gates will be connected directly to the pin. allowing a pin to float (or be driven) to a midsupply level can result in both the n- and p-channel devices in the input buffer simultaneously being partially on, which causes excess current and noise on the v dd /v ss power supply. port e inputs are exceptions because they are specifically designed to be driven by analog levels. figure 2-15 internal circuitry digital input-only pin if a digital input pin (see figure 2-15 ) is driven with voltages below v ss , the thick-field protection device [2] forms an inherent diode junction to v ss , which conducts when the pin voltage gets more than a diode drop below v ss . as the pin voltage is driven more negative with respect to v ss , current increases. these currents have a tendency to influence the die substrate in the area around the protection device, thus affecting the electrical characteristics of devices in the vicinity. when the pin current is increased to very high levels (typically more than 100 ma, specified limit is 25 ma), physical dam- age can result. as voltage at [1] is driven above v dd , the protection device will begin to conduct and tend to clamp the input voltage to protect input buffer [3]. the voltage at which this con- dition will occur varies significantly from lot to lot and over the operating temperature range. at room temperature, the pin typically does not draw any current until approxi- mately 20 v; at 125 , the pin may start conducting at a slightly lower level. up to this point, the pin appears to function normally and will return a logic one if read. as the pin p n v dd thick field protection pin n [1] [2] [3] input buffer
motorola pins and connections m68hc11 2-26 reference manual voltage increases, the thick-field protection device begins to conduct more current to the die substrate, which is v ss . there should be some external series impedance be- tween the pin and the input voltage source if the mcu will be used in a detrimental environment. if the input voltage is increased even further, the protection device [2] will avalanche, and the pin voltage will eventually fold back (typically to about 7 to 12 v). under these conditions, a parasitic bipolar transistor, which is not obvious from the mos schematic, is turned on and is holding the pin at the 7-volt level. this avalanche is still normally not destructive to the pin. since the foldback clamp level is relatively low impedance, the pin voltage cannot be raised further without supplying a large cur- rent. if the offending voltage source is increased to increase the pin current, the pin circuitry will be damaged (specified limit is 25 ma, typically takes more than 100 ma). gate oxides in these inputs are not intended to be exposed to voltages above 7 v for any significant amount of time. with the hcmos processing used in the MC68HC11a8, a latchup failure is unlikely unless legal drive limits are grossly exceed- ed. 2.4.4 internal circuitry analog input-only pin figure 2-16 shows the mos circuitry associated with an analog input-only pin. this mos logic is similar to that for a digital input-only pin except for the addition of the an- alog multiplexer [5] and the extra n-channel device below the buffer. the n-channel device [5] acts as an analog multiplexer and affects the behavior of an analog input pin when exposed to negative voltages. the n-channel device [4] allows the analog input pins to be driven by intermediate levels without causing the noise and current normally associated with the input buffer when its input is at a midsupply level. this device is only turned on for half an e-clock cycle during a digital read of port e. since the analog input pins (including the v ref pins) are only connected to n-channel devices and high- impedance gates, these pins can be driven with levels above v dd without the usual fear of latchup. this aspect is important because the analog reference supply is typi- cally independent of the v dd supply for noise isolation reasons. an analog input pin (see figure 2-16 ) responds very much like a digital input to illegal levels except that negative levels at the pin can affect a/d operations. the analog functions associated with these pins also present some special challenges to protec- tive interface circuits. although the n-channel devices [4] eliminates the need for ex- ternal pull-up or pulldown resistors on unused port e pins, a conservative designer would still terminate these pins to help prevent static damage.
m68hc11 pins and connections motorola reference manual 2-27 figure 2-16 internal circuitry analog input-only pin if the pin voltage is driven low enough relative to the gate voltage of the analog multi- plexer device, this n-channel device can turn on. a conductive path between the neg- ative pin and the a/d capacitor array may discharge the capacitors and disrupt any a/ d conversion in progress. the thick-field protection device and other circuit and layout measures around the n-channel multiplexer device are intended to prevent the pin voltage from becoming negative enough to turn on the multiplexer device. even with these internal protective measures, a cautious user should avoid negative levels on any a/d pin because a large negative transient could still disrupt an a/d conversion. an a/d conversion can be disrupted in this manner if any a/d pin experiences a seri- ous negative transient; the transient need not be on the pin associated with the con- version. external diode clamps to v dd are not necessarily a good idea on the analog inputs. leakage through an external diode would be significant in relationship to the pin leak- age current; thus, this extra leakage could affect the accuracy of analog conversion results. analog input pins can usually be protected by a low-pass filter with enough se- ries impedance to limit the pin voltage. the amount of series resistance is a trade-off between a high enough value to limit pin voltage and a low enough value to prevent pin leakage current from adversely affecting conversion results. conversion accuracy is specified for a maximum external series resistance of 10 k w . the worst-case spec- ified leakage current at the pin is 400 na (at room temperature, leakage is typically much less). the 400 na acting through 10 k w causes an absolute conversion error of minus one-fifth of a least significant bit (lsb) when v ref is 5.12 v, leaving only about one-quarter of an lsb for actual a/d circuit errors before the results would be out of specified limits. using a larger external resistance in series with an a/d pin may cause some inaccuracy due to the leakage current acting through this resistance, but the a/ d will still respond in a predictable manner. there may be valid system design reasons for choosing a high external series resistance (e.g., to minimize power consumption in p n v dd thick field protection pin n [1] [2] [3] input buffer n [4] [5] analog multiplexer n
motorola pins and connections m68hc11 2-28 reference manual a battery-based system). for additional detailed information concerning the a/d input pins, see 12.3 a/d pin connection considerations . 2.4.5 internal circuitry digital i/o pin figure 2-17 shows the mos circuitry for an mcu pin capable of operating as an input or an output. even when the pin is configured to disable the output driver circuitry, the mos transistors still affect the way the pin reacts to illegal levels. the p-channel de- vice of the output driver [3] forms an inherent diode to v dd , and the n-channel device forms an inherent diode to v ss , which is in parallel with the inherent diode of the thick- field protection device. figure 2-17 internal circuitry digital i/o pin when the pin is configured as a high-impedance input, input signals are clamped to within a diode drop of the v ss and v dd power-supply rails. when the pin is configured as an output, the p- or n-channel device provides a low-impedance path to v dd or v ss , respectively. the current into or out of the pin should be limited to prevent dam- age. the specified current limit is 25 ma although these pins can typically withstand transients of more than 100 ma at nominal room temperature. the port c and port d i/o pins of the m68hc11 can be configured as open-drain-type outputs. this configuration disables the gate signal to the p-channel device of the out- put buffer so the pin cannot be driven to an active-high logic level, but the p-channel device is still physically present and forms an inherent diode to v dd . in a few applica- tions, the situation will arise where two or more mcu i/o pins are tied to the same point. software would be arranged so that no more than one of these i/o pins is con- figured as an output at any time to avoid output driver contention. in these applications, the i/o pins should be configured for the open-drain mode so the output drivers are prevented from high-current contention. p n thick field protection pin n [1] [2] [3] input buffer v dd n p [4] [5] output buffer v dd
m68hc11 pins and connections motorola reference manual 2-29 2.4.6 internal circuitry input/open-drain-output pin two pins on the m68hc11 ( reset and moda/ lir) have high-impedance input func- tions as well as open-drain output functions (see figure 2-18 ). these pins are similar to i/o pins except that there is no p-channel device in the output driver. since the p- channel output device is not present, there is no inherent diode to v dd . in terms of negative illegal levels at these pins, there are two diodes clamping the pin to a diode drop below ground. in terms of positive levels above v dd , the n-channel output device starts to conduct before the thick-field protection device; thus, the clamp level for these pins will typically be lower than that for a digital input-only pin. as for any mcu pin, current should be limited to prevent damage. figure 2-18 internal circuitry input/open-drain-output pin 2.4.7 internal circuitry digital output-only pin output-only pins react to illegal levels exactly like i/o pins. figure 2-19 shows the mos circuitry for a digital output-only pin. figure 2-19 internal circuitry output-only pin p n thick field protection pin n [1] [2] [3] input buffer n [4] n-channel only output buffer v dd thick field protection pin n v dd n p output buffer
motorola pins and connections m68hc11 2-30 reference manual 2.4.8 internal circuitry modb/v stby pin the modb/v stby pin is unusual because it serves as a standby voltage source in ad- dition to acting as a mode select input (see figure 2-20 ). a mos switch automatically connects the internal ram power supply to the higher of v dd or v stby . if an illegal high level is applied to the modb/v stby pin, this illegal voltage is passed in to the in- ternal ram system. a minor elevation of v stby relative to v dd can be tolerated during mcu operation, but any significant elevation can result in incorrect reads of ram data. when a battery or other standby voltage source will be used to maintain ram contents in the absence of v dd , the modb/v stby pin should be driven by v dd (rather than the standby source) during normal operation. the modb/v stby pin should not be driven by a higher level than v dd , except during standby periods; during these periods, re- set should be driven low. figure 2-20 internal circuitry modb/v stby pin p n [3] input buffer pin [1] modb/v stby mos power switch [4] [5] [6] [7] power to ram v dd thick field protection n [2] n v dd v dd
m68hc11 pins and connections motorola reference manual 2-31 2.4.9 internal circuitry irq/v ppbulk pin the irq pin is used as a high-voltage (20 v) power source during factory testing. this high-voltage source supplies power for bulk programming operations because the in- ternal charge pump is not designed to provide enough current for these bulk program- ming operations. figure 2-21 shows the mos circuitry for the irq/v ppbulk pin. the irq/v ppbulk pin essentially reacts like an input-only pin to illegal levels. figure 2-21 internal circuitry irq/v ppbulk pin the normal v pp level used during testing is very near the level where the thick-field protection device begins to conduct. it is important to limit the current of the v pp power supply into the irq/v ppbulk pin with an external series resistor (typically 27 k w ) be- cause noise or overshoot can trigger the low-impedance foldback mechanism of the protection device. without a current-limiting resistor, the small metal line connecting the bonding pad to the pin input circuitry will instantly vaporize. normal users would not encounter this potential problem since the v pp function of the irq/v ppbulk pin is only intended for use by motorola. the current-limiting resistor has no adverse affect on the bulk programming process since the current requirements for eeprom pro- gramming are very small. 2.5 typical single-chip-mode system connections figure 2-22 is the schematic for a simple single-chip-mode system, which can be op- erated in normal single-chip or special bootstrap mode. this circuit can be used as the basis for any single-chip-mode application. in most cases, the circuitry for the power supply, oscillator, and mode selects can be used exactly as shown in this system. only specialized i/o circuitry specific to the application needs to be designed from scratch. all unused inputs are terminated in an appropriate manner. p n v dd thick field protection pin n [1] [2] [3] input buffer irq/v ppbulk [4] v pp nn
motorola pins and connections m68hc11 2-32 reference manual figure 2-22 basic single-chip-mode connections 4.7k mc34064 reset gnd in 1k 1 m f 10m 8.0 mhz 18 pf 18 pf 4.7k 4.7k 0.1 m f 4.7 m f system power 4.7k connect jumper for bootstrap mode reset xirq irq v v rh rl stby moda/ lir v modb/v dd v ss extal xtal MC68HC11a8 pa0/ic3 pa1/ic2 pa2/ic0 pa3/oc5/oc1 pa4/oc4/oc1 pa5/oc3/oc1 pa6/oc2/oc1 pa7/pai/oc1 pb0 pb1 pb2 pb3 pb4 pb5 pb6 pb7 strb pe4/an4 stra pe5/an5 pc0 pc1 pc2 pc3 pc4 pc5 pc6 pc7 pe6/an6 pd0/rxd pd1/txd pd2/miso pd3/mosi pd4/sck pd5/ ss pe7/an7 pe0/an0 pe1/an1 pe2/an2 pe3/an3 10k typ e v dd + v dd v dd v dd v dd v dd
m68hc11 pins and connections motorola reference manual 2-33 2.6 typical expanded-mode-system connections the schematic shown in figure 2-23 is for a fairly straightforward expanded-mode system, which can be operated in normal expanded mode or special test mode. this circuitry can be used as the basis for any expanded-mode application. in most cases, the circuitry for the power supply, oscillator, and mode selects can be used exactly as shown in this system. if additional memory or peripheral functions are added to the ad- dress and data buses, the loading should be reviewed to determine whether or not ad- ditional buffering is required. loading is generally limited by load capacitance before the dc drive capabilities of the mcu drivers are reached. at bus frequencies lower than 2 mhz, more capacitance can be driven before buffers are required. in applications where heavy bus loading occurs, it is necessary to increase power-supply bypass ca- pacitors to provide for these higher bus switching demands on v dd . the address decoding used in this example system is unusual in that the external eprom is decoded to appear in either of two memory areas. some commonly used terms to describe this type of decoding are partial decode, redundant mapping, and mirroring. in this system, the external eprom appears at $e000C$ffff and at $a000C$bfff so that the reset vector can be fetched out of this eprom whether the mcu is operating in normal expanded mode or special test mode. this mapping also allows the mcu to come out of reset in special test mode, check the contents of the eeprom-based config register (change config if necessary), and then change the operating mode to normal expanded mode. there are several potential advantag- es to starting a system this way (see 3.5.3 special test mode ). the 74hc138 decoder provides address-qualified read enable and write enable sig- nals for two 8-kbyte by 8 static rams. the other four outputs of this 74hc138 provide additional chip selects for additional ram or peripheral devices. since the r/ w signal drives one of the address selects of the 74hc138, there are four active-low read en- able outputs and four active-low write enable outputs. the timing for these outputs is controlled by the e clock and the propagation delay through the 74hc138 decoder. address and r/ w are stable long before the rising edge of the e clock. the decoding for the eprom was done with two sections of a quad nand gate. ad- dress valid time controls the chip select access time of the eprom. this chip select decode provides for a longer access time than the chip select arrangement on the rams because eproms are typically slower than static rams. the e clock controls the output enable of the eprom, which typically has a much shorter setup time re- quirement than the chip-select input to the eprom. since address line 14 (addr14) is not included in the decode for the eprom, the eprom will appear twice in the memory map: at $a000C$bfff where addr14 is low and at $e000C$ffff where addr14 is high. a few potential address conflicts can occur in this system. the on-chip rom and/or on-chip eeprom can conflict with the external eprom. for the purposes of this ex- ample, it is assumed that the internal rom will not be used and will be disabled by the romon control bit in the config register. the potential for conflict with the ee- prom poses no concern in normal expanded mode because the external mcu data bus is high impedance and ignored during reads of the internal eeprom. in special
motorola pins and connections m68hc11 2-34 reference manual test mode, there is a potential for an undesirable conflict if the eeprom is read while the irv function is enabled (see 2.7.2 internal read visibility (irv) . although this conflict would not typically be destructive, it would increase power consumption and generated noise. in this example system, the special test mode would only be in effect for a short time after reset, and reads of the internal eeprom could easily be avoided during this time.
m68hc11 pins and connections motorola reference manual 2-35 figure 2-23 basic expanded mode connections (sheet 1 of 2) v dd + 4.7k mc34064 v dd reset v dd gnd in 1k 1 m f v dd 10m 8.0 mhz 18 pf 18 pf v dd 4.7k 4.7k 0.01 m f 10 m f system power connect jumper for test mode reset xirq irq v v rh rl moda/ lir v stby modb/v dd v ss extal xtal MC68HC11a8 pa0/ic3 pa1/ic2 pa2/ic0 pa3/oc5/oc1 pa4/oc4/oc1 pa5/oc3/oc1 pa6/oc2/oc1 pa7/pai/oc1 a8 a9 a10 a11 a12 a13 a14 a15 pe4/an4 pe5/an5 pe6/an6 pd0/rxd pd1/txd pd2/miso pd3/mosi pd4/sck pd5/ ss pe7/an7 pe0/an0 pe1/an1 pe2/an2 pe3/an3 v dd 10k typ e 4.7k 4.7k 1 m f as ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 oe q0 q1 q2 q3 q4 q5 q6 q7 le d0 d1 d2 d3 d4 d5 d6 d7 74hc373 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 d0 d1 d2 d3 d4 d5 d6 d7 r/ w e as r/ w control bus data bus address bus
motorola pins and connections m68hc11 2-36 reference manual figure 2-24 basic expanded mode connections (sheet 2 of 2) control bus data bus address bus d0 d1 d2 d3 d4 d5 d6 d7 a0 a1 a2 a3 a4 a5 a6 a7 d0 d1 d2 d3 d4 d5 d6 d7 a8 a9 a10 a11 a12 8k x 8 ram oe d0 d1 d2 d3 d4 d5 d6 d7 cs a0 a1 a2 a3 a4 a5 a6 a7 d0 d1 d2 d3 d4 d5 d6 d7 a8 a9 a10 a11 a12 8k x 8 eprom d0 d1 d2 d3 d4 d5 d6 d7 a0 a1 a2 a3 a4 a5 a6 a7 d0 d1 d2 d3 d4 d5 d6 d7 a8 a9 a10 a11 a12 8k x 8 ram a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 v dd d0 d1 d2 d3 d4 d5 d6 d7 10k typ y0 y1 y2 y3 y4 y5 y6 y7 a0 a1 a2 g g1 g2 a14 a15 a13 rd we rd we e r/ w e r/ w a15 a13 74hc138
m68hc11 pins and connections motorola reference manual 2-37 2.7 system development and debug features the designers of the m68hc11 carefully considered the system development needs of the user. since smaller users cannot afford thousands of dollars for a development system, the m68hc11 was specifically designed to accommodate low-cost develop- ment tools. the m68hc11 evb evaluation board and m68hc11 evm evaluation mod- ule are two examples of such low-cost tools. several customers have also built small plug-in modules that emulate the MC68HC11a8 for product development purposes. the small size of these plug-in emulators is possible because of the development fea- tures designed into the m68hc11. 2.7.1 load instruction register ( lir) the lir signal is intended as a debugging aid. this signal is driven to active low for the first bus cycle of each new instruction, making it easy to reverse assemble (disas- semble) instructions from the display of a logic analyzer. 2.7.2 internal read visibility (irv) during debugging of an application, it is useful to see what is being read from internal registers and memory locations. the irv feature provides this capability. this feature should usually be disabled during normal operation of the system due to the possibility of bus conflicts. the irv feature is controlled by the irv bit in the hprio register. when the irv bit is one, the data from a read of an internal register or memory location is driven out on the data bus so it can be monitored by a logic analyzer. if the irv bit is zero, the irv function is disabled, and the data bus is undriven during reads of an internal address. special restrictions apply to the use of the irv bit and function. when the mcu is reset in normal modes, the irv bit is initially zero. in all but the newest derivatives in the m68hc11 family, the irv bit may not be written to one in the normal modes. in special test and bootstrap modes, the irv bit is initially one and may be written to zero after which it becomes a read-only bit. care should be used if the irv function is enabled. during reads of an internal ad- dress, the data bus is driven out even though the r/ w line indicates that the bus direc- tion is toward the mcu. some external device may also be trying to drive the data lines, which leads to an undesirable bus contention. in a test or debugging situation, special address decode logic can be used to prevent such contention. it would be ex- pensive and inappropriate to have this additional decode logic on all normal mode sys- tems; thus, the irv function was only provided in the special test and bootstrap modes. due to several customer requests for the irv function in normal modes, the logic was changed to allow the function to be enabled in normal modes on new ver- sions of the m68hc11. the default condition in normal modes is still irv equals zero, which disables the function. if a user specifically wants the irv function, irv may be written to one, and the user becomes responsible for avoiding bus contentions. irv can be written to one at any time unless it has previously been written to zero. if the irv bit is written to zero, the function becomes disabled until the next reset sequence.
motorola pins and connections m68hc11 2-38 reference manual 2.7.3 mc68hc24 port replacement unit the mc68hc24 pru is a gate array that emulates the single-chip mode functions of ports b and c, which are lost to the expansion bus function when the mcu is operated in expanded modes. the expanded mode permits program development in an exter- nal eprom. a system consisting of an m68hc11 in expanded mode, an mc68hc24, an hc373 octal latch, and an external eprom performs like the MC68HC11a8 oper- ating in single-chip modes, thus allowing an application program to be developed and tested before a masked rom pattern is ordered. the logic in the m68hc11 was specifically designed to permit emulation of single-chip functions with the mc68hc24. first, the addresses associated with ports b and c and their handshake i/o functions are treated as external addresses when the mcu is op- erating in expanded modes. next, the interrupts associated with the handshake i/o system are vectored to the same address as irq interrupts. thus, the interrupt output of the mc68hc24 can be connected to the irq interrupt input of the mcu, and hand- shake interrupts will be treated the same as internal handshake functions. the m68hc11 allows registers and/or internal ram to be remapped to any 4-kbyte bound- ary. the mc68hc24 copies this logic so that the registers in the mc68hc24 will au- tomatically track the internal remapping logic. software written on an expanded system, including an mc68hc24, will operate exactly as it would in the internal rom of an MC68HC11a8 in single-chip mode.
m68hc11 configuration and modes of operation motorola reference manual 3-1 section 3 configuration and modes of operation this section discusses the mechanisms that allow the MC68HC11a8 to conform to a wide variety of applications. these mechanisms include hardware mode selection cir- cuitry, a nonvolatile eeprom-based configuration register, and protected control reg- ister bits. the majority of the control bits in the MC68HC11a8 are accessible at any time by software and will be discussed throughout this manual. the term mode is used in more than one context in discussing the microcontroller unit (mcu). for example, the serial peripheral interface (spi) is said to be in either the master or slave mode, the parallel i/o system is said to be in simple strobed mode, full-input handshake mode, or full-output handshake mode. in most cases, there is no confusion about what the term mode refers to; however, the use of the term mode in conjunction with stop and wait is often misunderstood. stop and wait are actu- ally modes of operation of the central processing unit (cpu) as opposed to single-chip and expanded modes, which are modes of operation of the mcu integrated circuit. in this section, the mcu operating modes and other mechanisms controlling the basic configuration of the mcu are discussed. very few mcu functions are influenced by the mode of operation. for example, the timers, analog-to-digital converter (a/d), and serial i/o functions all work the same in expanded modes as they do in single-chip modes. the parallel i/o functions of 18 pins are lost in the expanded modes but can be regained with a special, external, port-re- placement chip called the mc68hc24. in the two special modes of mcu operation, some special testing functions become accessible, including the ability for software to change the mcu mode. 3.1 hardware mode selection there are only two fundamental modes of operation for the MC68HC11a8 mcu: sin- gle chip and expanded. each mode has a normal variation and a special variation. these four mode variations are selected by the levels on the mode a (moda) and mode b (modb) pins during reset. the special variation of single-chip mode is called special bootstrap mode; the special variation of the expanded mode is called special test mode. the special bootstrap mode allows programs to be downloaded through the on-chip serial communications interface (sci) into internal random-access mem- ory (ram) to be executed. the bootloaded program is used for a variety of tasks such as loading calibration values into internal electrically erasable programmable read- only memory (eeprom) or performing diagnostics on a finished module. the boot- strap mode is a special users mode, not a factory test mode. the special test mode, which is intended primarily for factory testing, is seldom used by the user except for emulation, development, or in other rare circumstances.
motorola configuration and modes of operation m68hc11 3-2 reference manual 3.1.1 hardware mode select pins the hardware mode select mechanism starts with the logic levels on the moda and modb pins while the mcu is in the reset state. the logic levels on the moda and modb pins are fed into the mcu by way of a clocked pipeline path. the levels cap- tured are those that were present part of a clock cycle before the reset pin rose, which assures there will be a zero hold-time requirement on the mode select pins rel- ative to the rising edge at the reset pin. the captured levels determine the logic state of the special mode (smod) and mode a select (mda) control bits in the highest pri- ority interrupt (hprio) register. these two control bits actually control the logic circuits involved in hardware mode selection. table 3-1 summarizes the operation of the mode pins and mode control bits. after reset rises, the mode select pins no longer influence the mcu operating mode. the moda pin serves the alternate function of load instruction register ( lir) when the mcu is not in reset. the open-drain active-low lir output pin drives low during the first e-clock cycle of each instruction. the modb pin serves the alternate function of a standby power supply (v stby ) to maintain ram contents when v dd is not present. the power-saving mode, stop, is an alternate way to save ram contents, which does not require a separate standby power source. 3.1.2 mode control bits in the hprio register the following register and paragraphs show the hprio register. the four low-order bits (psel[3:0]) are not related to the mode select logic and will be discussed in sec- tion 5 resets and interrupts . the hprio register may be read at any time, but the four high-order bits may only be written under special circumstances. usually, control bits for unrelated on-chip systems would not be mixed in the same register. rboot read bootstrap rom can be written only while smod equals one 1 = bootstrap rom enabled at $bf40C$bfff 0 = bootstrap rom disabled and not present in memory map the rboot control bit enables or disables the special bootstrap control rom. this table 3-1 hardware mode select summary inputs mode description control bits in hprio (latched at reset) modb moda rboot smod mda irv 1 0 normal single chip 0000 1 1 normal expanded 0010 0 0 special bootstrap 1101 0 1 special test 0111 hprio highest priority i-bit interrupt and miscellaneous $103c bit 7 654321 bit 0 rboot smod mda irv psel3 psel2 psel1 psel0 reset: (refer to table 3-1 )
m68hc11 configuration and modes of operation motorola reference manual 3-3 192-byte, mask-programmed rom contains the firmware required to load a users program through the sci into the internal ram and jump to the loaded program. in all modes other than the special bootstrap mode, this rom is disabled and does not oc- cupy any space in the 64 kbyte memory map. although it is zero when the mcu comes out of reset in test mode, the rboot bit may be written to one while in special test mode. smod special mode may be written to zero but not back to one 1 = special mode variation in effect 0 = normal mode variation in effect mda mode a select can be written only while smod equals one 1 = normal expanded or special test mode in effect 0 = normal single-chip or special bootstrap mode in effect irv internal read visibility can be written only while smod equals one; forced to zero if smod equals zero 1 = data driven onto external bus during internal reads 0 = data from internal reads not visible on expansion bus (levels on bus ignored) the irv control bit is used during factory testing and sometimes during emulation to allow internal read accesses to be visible on the external data bus. care is required to avoid data bus contention while irv is active because the bidirectional data bus is driv- en out during reads of internal addresses, even though the r/ w line suggests the data bus is in the high-impedance read mode. in normal modes, this function is disabled; thus, complex decode logic is not required to protect against accidental bus conflicts. 3.2 eeprom-based config register the nonvolatile configuration (config) register allows additional flexibility in the mcu that would otherwise be provided by a more complex hardware mode select structure. by using eeprom to implement the config register, these system controls are re- tained even when no power is applied to the mcu. the functions controlled by this reg- ister are characteristics that must be inherently known to the mcu system as it comes out of the reset state. ordinary software-accessible control bits would not effectively regulate these controls. 3.2.1 operation of config mechanism the config register actually consists of an eeprom byte (separate from the 512- byte eeprom array), a static register that holds the configuration information during operation, and the associated logic, which controls the transfer of information from the eeprom byte to the working static register. programming and erasure of this register use the same logic used for programming and erasure of the 512-byte eeprom ar- ray. reads of this register return the contents of the static working register, not the ee- prom byte. during any reset, the contents of the eeprom byte are transferred to the working static register over the data bus. due to this mechanism, changes to the ee- prom config location are not visible and do not alter the operation of the mcu until
motorola configuration and modes of operation m68hc11 3-4 reference manual after a subsequent reset. some versions of the m68hc11 family allow the config working register to be writ- ten directly as a normal control register while operating in the special mode variations. this capability is included primarily to accelerate product testing but could be useful to the user in some applications. in versions that have this ability, the mcu could be reset in one of the special modes. the config register could be checked or written to any desired value; then the mode could be written to a normal mode to re-enable system- protection mechanisms. this procedure is independent of the eeprom byte and the transfer during reset. only some versions of the m68hc11 offer this capability. risk factors are associated with operating in a special mode; therefore, keep the time be- tween reset and writing the mode control bits back to a normal mode as short as pos- sible to minimize these risks. 3.2.2 the config register the config register is an unusual control register used to enable or disable rom, eeprom, the computer operating properly (cop) watchdog system, and, optionally, the eeprom security feature of the mcu. unlike ordinary control registers, config retains its contents even when there is no power applied to the mcu. the contents are retained when the mcu is completely removed from a system (e.g., when shipped from the motorola factory). in this way, the control bits in the config register are like mask-programmed options. unlike mask options, the contents of this register can be altered after the mcu is manufactured to meet the customers specific requirements. the config register is read like any other memory location. the contents of the work- ing static register are returned on such reads as previously described. the config register is erased and programmed like an eeprom location rather than being written as other registers. the programming and erase operations alter the eeprom byte, which does not alter the operation of the mcu until after a subsequent reset operation. the programming and erase procedures, which are the same as those used to pro- gram eeprom locations, use the pprog register and are discussed in 4.3 ee- prom . the following register and paragraphs describe the config register and control bits of the MC68HC11a8. for specific information about the config register of other m68hc11 family members, refer to the technical summary for that member. nosec eeprom security disabled a special security feature is available on the MC68HC11a8 if it is requested at the time a user submits a mask rom pattern. once this feature is enabled at the mask-pro- gramming level, the user activates it by programming the nosec bit to zero. while nosec is zero, the mcu can only be reset in single-chip modes (normal single chip config system configuration $103f bit 7 654321 bit 0 0000 nosec nocop romon eeon reset: 0000see 3.2.1 operation of config mechanism
m68hc11 configuration and modes of operation motorola reference manual 3-5 or special bootstrap). this restriction is accomplished by forcing the mda control bit to zero rather than allowing it to follow the moda pin level at the rising edge of reset. by disallowing expanded modes, a software pirate is prevented from seeing the data in eeprom or ram because there is no external address/data bus in single-chip modes. the software pirate can see what is in the on-chip rom by disabling the security op- tion, which can only be accomplished after the contents of eeprom and ram have been erased. when a secured part is reset in bootstrap mode, the firmware in the small bootloader program will not proceed with bootloading until the eeprom, ram, and config register have been successfully erased. when a secured part is operat- ed in normal single-chip mode, the users program in rom is responsible for keeping the mcu secured. the config register in current versions of the MC68HC11a8 can- not be altered except in special bootstrap and special test modes. nocop cop watchdog system disabled the default erased state of this bit corresponds to cop system off. 1 = the cop system is disabled and does not generate system resets. 0 = the cop system is enabled as the mcu comes out of reset. a software service mechanism must be periodically completed prior to cop time-out to avoid a system reset. this service will only occur at the proper repeating rate if the software is executing in the expected, orderly fashion. if a software failure occurs, the watchdog will time out and will generate a system reset to force the mcu to return to proper operation. the cop watchdog mechanism is discussed in detail in section 5 resets and interrupts . romon enable on-chip rom the default erased state of this bit corresponds to rom enabled. 1 = the 8-kbyte on-chip program memory is enabled. 0 = the 8-kbyte rom is disabled and takes no space in the memory map. in the normal single-chip operating mode, this control bit is overridden so that rom is always enabled. in expanded modes, turning off the rom with this bit allows the reset and interrupt vectors to be fetched from external memories; therefore, the user need not know where vectors should point at the time the mcu is manufactured. eeon enable on-chip eeprom the default erased state of this bit corresponds to eeprom enabled. 1 = the 512-byte on-chip eeprom memory enabled at locations $b600C$b7ff. 0 = the 512-byte eeprom is disabled and takes no space in the memory map. some versions of the m68hc11 family have additional control bits in this register. for example, the mc68hc811a2 uses the upper four bits to remap its 2-kbyte eeprom to the upper half of any 4-kbyte page of memory. this reference manual is based pri- marily on the MC68HC11a8; specific information about other family members can be found in the technical summaries. the erased state of config is $0f on an MC68HC11a8. the MC68HC11a1 is the same die as the MC68HC11a8 but comes from the factory with $0d in config to dis- able the internal 8-kbyte masked rom. similarly, the MC68HC11a0 version of the part comes with $0c in config to disable both the 8-kbyte rom and 512-byte ee- prom. the config byte is not part of the 512-byte eeprom. if the config register
motorola configuration and modes of operation m68hc11 3-6 reference manual of an MC68HC11a1 or MC68HC11a0 device is erased to $0f, the internal rom and eeprom memories become enabled but are not necessarily useful. the rom of an MC68HC11a1 or MC68HC11a0 part may contain a customers program (with their permission) or a defective program. the eeprom of an MC68HC11a0 part could be partially/completely broken and should not be used because the error could be related to temperature or voltage. therefore, the eeprom might check as flawless but later fail when least expected. the upper four bits are not implemented in the working static register and always read zero. although the corresponding bits in the eeprom byte are implemented, they are not visible to the user. the erased state of the config register in the mc68hc811a2 version is $ff, which means the 2-kbyte eeprom is enabled in the area from $f800C$ffff when the part comes from the motorola factory. to use the part, the user must have a meaningful reset vector at $fffe,ffff or must connect the mode pins so the system will come out of reset in one of the special modes. the reset vector can be programmed into the internal eeprom before installing the part into a finished system, or the eeprom can be moved out of the way (by programming the config register) so an external mem- ory in the end system can provide the reset vector. 3.3 protected control register bits in the MC68HC11a8, several sensitive control registers and bits are protected against writes except under special circumstances. the protect mechanisms include the ability to write these bits only within the first 64 bus cycles after any reset and/or the ability to write them only one time after each reset. these bits control the basic configuration of the mcu where an accidental write could cause serious system problems that is, these protections make it practical to include software-controlled features that might otherwise be excluded. as new members of the m68hc11 family are developed, ad- ditional control bits could fall into this category, but in the MC68HC11a8, only three control registers are involved (init, tmsk2, and option). some users have ex- pressed concern about being able to write all of these control bits within 64 cycles, which will not be a problem since only three writes are required. because these protect mechanisms are overridden in the special operating modes, these bits may be changed repeatedly during testing without going through a reset se- quence. if the mcu is going to be changed to a normal mode variation after being reset in a special mode, write to the protected registers before writing the smod control bit to zero. 3.3.1 ram and i/o mapping register (init) ram[3:0] ram map position these four bits, which specify the upper hexadecimal digit of the ram address, control init ram and i/o mapping register $103d bit 7 654321 bit 0 ram3 ram2 ram1 ram0 reg3 reg2 reg1 reg0 reset: 00000001
m68hc11 configuration and modes of operation motorola reference manual 3-7 the position of the ram in the memory map. by changing these bits, the ram can be repositioned to the beginning of any 4-kbyte page in the memory map. after reset, these bits are zeros ($0); thus, the ram is initially positioned from $0000C$00ff. if these four bits are written to ones ($f), the ram moves to $f000C$f0ff. the follow- ing explanation of the init register discusses what happens when ram or registers are mapped to the same area of memory as some other internal resource. reg[3:0] 64-byte register block position these four bits, which specify the upper hexadecimal digit of the address for the 64- byte block of internal registers, control the position of these registers in the memory map. by changing these bits, the register block is repositioned to the beginning of any 4-kbyte page in the memory map. after reset, these bits are 0001 ($1); therefore, the registers are initially positioned from $1000C$103f. if these four bits are written to ones ($f), the registers move to $f000C$f03f. the following explanation discusses what happens when ram or registers are mapped to the same area of memory as some other internal resource. the init register allows software to reposition the internal 256-byte ram and/or 64- byte register space to any 4-kbyte page boundary in the 64-kbyte memory map. there are two main reasons a user might want this capability. first, this capability al- lows the user to position ram, i/o registers, or both in the direct addressing mode range ($0000C$00ff). instructions that use the direct addressing mode assume the upper eight bits of the address are $00; thus, these instructions take up less program memory space and operate faster than the equivalent extended addressing mode in- structions. the second reason for remapping ram or registers would be to make the mcu compatible with the memory map of an existing system. for example, the mc6801 mcu is not compatible with the motorola exorciser ? . the mdos ? disk- operating system software requires ram to exist from $0000C$7fff, rom routines to exist from $e800C$ebff, and system i/o devices to exist from $ec00C$f000. be- cause the mc6801 mcu has internal ram and registers in $0000C$00ff that cannot be disabled or moved, it cannot be made compatible with the exorciser. however, the MC68HC11a8 can disable its internal rom with the config register, and the ram and registers can be remapped to $d000 and $c000, respectively, by writing $dc to the init register. this procedure makes the MC68HC11a8 compatible with the exorciser system without requiring changes to the existing mdos software. a vari- ation on this second reason for remapping ram and registers would be to make max- imum use of an external 32-kbyte ram in the lower half of the memory map. users not needing this capability can leave the ram and i/o registers in their default locations ($0000C$00ff for ram and $1000C$103f for registers). since the init reg- ister becomes write protected shortly after reset, the user need not worry about acci- dental changes due to a software error. the internal address decode circuitry automatically protects against conflicts among internal resources or between an internal and external resource. when an internal re- source is read, the external data bus is ignored (even if some external device tries to drive the data bus) so the cpu will read valid data. if the internal ram and/or i/o reg- ister spaces are remapped so an overlap occurs between ram, register space, or rom, priority logic disables all but the highest priority resource. for example, consider
motorola configuration and modes of operation m68hc11 3-8 reference manual the case of an expanded mode system where rom is enabled and both ram and reg- isters have been remapped to $f000. for accesses from $f000C$f03f, rom and ram are disabled, and registers have highest access priority. from $f040C$f0ff, rom is disabled, and ram has access priority. some users have questions about the priority of access for unused register locations in the 64-byte register space or the priority of registers in an external mc68hc24. in the previous example, $f035 would correspond to an unused location in the 64-byte register space (the register block was moved from its usual position of $1000C$103f such that it overlaps ram and rom at $f000). reads of this address access the un- driven internal data bus, and any data present on the data bus pins is ignored. six lo- cations in the 64-byte register space become external accesses when the MC68HC11a8 is operating in an expanded mode. this process allows the mc68hc24 to properly emulate the internal parallel i/o functions associated with the 18 mcu pins, which are dedicated to the multiplexed expansion bus. again referring to the earlier example, if any of these six addresses are accessed, the internal rom and ram are disabled so the cpu gets valid data from the external mc68hc24, which is consid- ered a part of the internal register space. the six locations of interest are $x002C$x007 (pioc, portc, portb, portcl, one reserved location, and ddrc). although x is usually one, it was changed to $f by software in this example. 3.3.2 protected control bits in the tmsk2 register the following register diagram and paragraphs describe the time-protected timer pres- cale select bits (pr[1:0]) in the timer mask register 2 (tmsk2). the upper four bits of this register, which are related to the timer and pulse accumulator subsystems, will be discussed in section 10 main timer and real-time interrupt and sec- tion 11 pulse accumulator . bits 3 and 2 are not implemented and always read as zeros. pr[1:0] timer prescaler select these two bits select the prescale rate for the main 16-bit free-running timer system. the following table shows the relationship between the prescale factor and the value of these control bits. a prescale factor of one corresponds to a timer count rate of e clock divided by one; a prescale factor of 16 corresponds to a timer count rate of e clock divided by 16. in normal modes, this prescale rate can only be changed once within the first 64 bus cycles after reset, and the resulting count rate stays in effect until the next reset. tmsk2 timer mask register 2 $1024 bit 7 654321 bit 0 toi rtii paovi paii 0 0 pr1 pr0 reset: 00000000
m68hc11 configuration and modes of operation motorola reference manual 3-9 3.3.3 protected control bits in the option register the following register and paragraphs discuss the time-protected control bits on the option (option) control register. bit 2 of this register is not implemented and always reads zero. adpu, csel, and cme are not time-protected bits. irqe configure irq for edge-sensitive-only operation the default configuration is irqe equals zero or level-sensitive irqs. 1= irq is configured for edge-sensitive-only operation. falling edges at the irq pin are latched until the irq is honored. 0= irq is configured for level-sensitive operation. irq interrupts are requested by a low level on the irq pin. the low level must remain until the interrupt service routine does something to acknowledge the source of the interrupt. level-sen- sitive operation allows more than one source to be connected to the irq pin in a wired-or configuration. dly enable oscillator start-up delay 1 = a delay of approximately 4,000 e-clock cycles is imposed as the mcu is started up from the stop power-saving mode. this delay is intended to allow the crys- tal oscillator to stabilize. the actual time required for a crystal oscillator to sta- bilize depends on external components and physical layout. as far as the mcu is concerned, it is not necessary for the oscillator to be stable at its operating frequency because the MC68HC11a8 is a fully static processor that can oper- ate at frequencies down to dc. this delay is provided for the convenience of those applications requiring proper timing measurements soon after restart, thus requiring a stable oscillator. 0 = the relatively long oscillator startup delay coming out of stop is bypassed, and the mcu resumes processing within about four bus cycles. cr[1:0] cop timer rate select bits the mcu internal e clock is first divided by 2 15 before it enters the cop watchdog sys- tem. the cr1 and cr0 control bits control a further scaling factor for the watchdog timer as shown in table 3-2 . the columns at the right of the table show the resulting watchdog time-out periods for three typical oscillator frequencies. after reset, the time- out period is configured for the shortest time-out period by default. in normal operating modes, these bits can only be written once, and that write must be within 64 bus cycles pr1 pr0 prescale factor 001 014 108 1116 option system configuration options $1039 bit 7 654321 bit 0 adpu csel irqe dly cme 0 cr1 cr0 reset: 00010000
motorola configuration and modes of operation m68hc11 3-10 reference manual after reset. the cop system is discussed in detail in section 5 resets and in- terrupts . 3.4 normal mcu operating modes the normal modes of operation are selected by having a logic one on the modb pin during reset. the reset vector is fetched from addresses $fffe,ffff, and program execution begins from the address indicated by this vector. in normal single-chip mode, the internal 8-kbyte program memory is enabled in this memory space so the reset vector is fetched from this internal rom. in normal expanded mode, the internal 8-kbyte rom may or may not be enabled, depending on the romon bit in the con- fig register. if the internal rom is on, the reset vector is fetched from within this rom; otherwise, it is fetched from external memory addresses $fffe,ffff. 3.4.1 normal single-chip mode the normal single-chip mode is selected by a logic one on the modb pin and a logic zero on the moda pin during reset. because the single-chip modes do not require any external address and data bus functions, port b, port c, strobe a (stra), and strobe b (strb) pins are available for general-purpose parallel i/o. in this mode, all software needed to control the mcu is contained in internal memories. the romon control bit in the eeprom-based config register is overridden in nor- mal single-chip mode to force the internal 8-kbyte rom on. this procedure is required because there must be a valid reset vector for the mcu to operate in a logical manner. 3.4.2 normal expanded mode the normal expanded mode is selected by having a logic one on both the modb pin and moda pin during reset. this mode of operation allows external memory and pe- ripheral devices to be accessed by a time-multiplexed address/data bus. by multiplex- ing the low-order eight bits of address with data on the port c pins, only 18 pins are needed to provide an 8-bit data bus, a 16-bit address bus, and two bus control lines. the low-order address lines are separated from data with an external transparent latch such as a 74hc373, which is clocked by the address strobe (as) signal. all bus cycles, whether internal or external, execute at the e-clock frequency (no throughput penalty for external devices). the maximum bus frequency for the MC68HC11a8 is 2.1 mhz, which is comparable to the fastest external eproms available at the time the m68hc11 was introduced. section 2 pins and connections gives more de- table 3-2 watchdog rates vs. crystal frequency cr1 cr0 e + 2 15 divided by crystal frequency 2 23 hz 8 mhz 4 mhz nominal time-out 0 0 1 15.625 ms 16.384 ms 32.768 ms 0 1 4 62.5 ms 65.536 ms 131.07 ms 1 0 16 250 ms 262.14 ms 524.29 ms 1 1 64 1 s 1.049 s 2.1 s 2.1 mhz 2 mhz 1 mhz bus frequency (e clock)
m68hc11 configuration and modes of operation motorola reference manual 3-11 tailed information on the use of the expansion bus, including a discussion of an ex- panded-system example. for emulation purposes, there is a special companion chip called the mc68hc24 port replacement unit (pru). this device reconstructs the parallel i/o functions that are lost to the 18 expansion bus lines. software developed on an expanded system, which includes an mc68hc24, can later be submitted as a masked rom pattern. the result- ing custom-rom part can then be operated in the single-chip mode, and all parallel i/ o functions will work as they did in the expanded system. usually, the mc68hc24 companion chip would not be used as a general-purpose, peripheral i/o chip because cheaper ways exist to add general-purpose i/o to an expanded system. 3.5 special mcu operating modes the special mode variations are selected by having a logic zero on the modb pin dur- ing reset. in the special mode variations, the reset and interrupt vectors are located at $bfc0C$bfff, and software has access to special test features. one of these special test features (the disable resets (disr) control bit in the test1 control register) tem- porarily disables the cop watchdog and clock monitor reset functions. all the special functions and privileges are available in the special test mode and special bootstrap mode. since the reset vectors are located at $bffe,bfff, the internal 8-kbyte rom cannot interfere with the vectors. the expanded special test mode assures that the reset vec- tor is fetched from external memory even if the internal 8-kbyte rom is enabled. in special bootstrap mode, an on-chip bootloader firmware rom is enabled at addresses $bf40C$bfff so the reset vector is fetched from this internal rom. the smod control bit is latched as logic one when the mcu is reset in the special modes. while smod is a one, special test functions and privileges are available. rboot and mda can be turned on or off, and smod and irv can be turned off but not back on. thus, the operating mode of the mcu can be changed, but once the mode is changed to a normal mode (smod = 0), the privileges are revoked. an impor- tant, often overlooked application of this privilege is the ability to reset the mcu in bootstrap mode, which is a single-chip mode, then change the mda bit to one to en- able the multiplexed expansion bus. on present mask sets of the MC68HC11a8 (b96d and newer), the smod bit must be set to one to allow programming of the eeprom-based config register. in some m68hc11 family members, the eeprom-based config register can be written in special modes as if it were an ordinary static register. this privilege is not available in the original MC68HC11a8 but is present in the mc68hc811a2. another group of control bits in the mcu have special protection mechanisms to pre- vent accidental writes while operating in normal modes. these protections include write permission only within the first 64 e-clock cycles after reset and/or the ability to write these bits only one time. while in either special mode, these protections are over- ridden, and these control bits may be written as if they were ordinary control bits. for a detailed description of these protection mechanisms, see 3.3 protected control
motorola configuration and modes of operation m68hc11 3-12 reference manual register bits . a special register (test1) becomes accessible in the special modes. this register re- verts to all zeros and cannot be written when smod is zero (normal modes). other than the disr control bit in this register, the user should not be interested in the oper- ation of these bits since they are only useful for factory testing of the mcu. two other control bits in the sci baud-rate control register are similarly enabled only in the spe- cial modes. 3.5.1 testing functions control register (test1) the following register and paragraphs discuss the test1 control register. testing functions are not recommended for use by the user since they may change at any time to meet the manufacturing requirements of motorola; however, brief descriptions of these testing functions will be presented. occasionally, knowledge of these functions will help a user understand what is happening if one of these functions is accidentally invoked during development of an application. *the disr control bit resets to one in special modes. tilop test illegal opcode can be written only while smod equals one 1 = enable illegal opcode testing function 0 = function disabled in factory test equipment, information presented to the data bus pins is independent of the address coming from the mcu. in normal systems, the address outputs from the mcu enable a specific location in a memory device so the data presented to the mcu is specifically related to the address. the tilop works in conjunction with the lir pin to allow testing of illegal opcodes on consecutive bus cycles rather than requiring the time-consuming interrupt service normally associated with illegal opcodes. one con- sequence of the implementation of this function is that the address bus begins to dec- rement after the first illegal opcode is detected at the data bus. since there is no cause-effect relationship between address and data on the factory test equipment, this unusual address bus activity poses no difficulty for factory testing of illegal opcodes. however, this unusual address bus activity makes the illegal opcode test function un- usable in a normal system. occr output condition code register status to timer port can be written only while smod equals one 1 = the condition code register bits (h, n, z, v, and c) are driven out of the five most significant bits of port a (bits [7:3], respectively), which allows the cpu op- eration to be verified without the burden of complex branching routines. note test1 testing functions control register $103e bit 7 654321 bit 0 tilop 0 occr cbyp disr fcm fcop tcon reset: 00000*000
m68hc11 configuration and modes of operation motorola reference manual 3-13 while occr is set to one, the internal 8-kbyte rom is disabled, regardless of the states of the romon bit in the config register or the tcon bit in the test1 register. 0 = function disabled; port a operates as in normal modes. cbyp timer divider chain bypass can be written only while smod equals one 1 = the 16-bit free-running timer is divided into 8-bit halves, and the prescaler is bypassed. the e clock directly drives both halves of the timer. this function greatly reduces testing time for the main timer system. 0 = timer system operates normally. disr disable resets from cop and clock monitor can be written only while smod equals one; forced to zero if smod equals zero 1 = regardless of other control bit states, the cop and clock monitor systems do not generate a system reset. this function assures that testing operations are not interrupted by the cop or clock monitor protection mechanisms. 0 = cop and clock monitor resets operate normally. note users of the special bootstrap mode often forget that this bit is reset to a one in the bootstrap mode. if a bootloaded program uses one of these reset functions, this bit must be explicitly cleared by the loaded program. this is probably the only test-related control bit that is of interest to the user. fcm force clock monitor failure can be written only while smod equals one 1 = writing a logic one to this location generates an immediate clock monitor failure reset if the clock monitor enable (cme) bit in the option register is also set. 0 = system operates normally. the disr control bit has priority over this bit and inhibits the forced reset functions. fcop force cop watchdog time-out can be written only while smod equals one 1 = writing a logic one to this location generates an immediate cop failure reset if either the nocop bit in the config register is zero or the tcon bit in the test1 register is one. 0 = system operates normally. the disr control bit has priority over this bit and inhibits the forced reset functions. tcon test configuration can be written only while smod equals one 1 = overrides the specifications in the config register so that cop is enabled and rom and eeprom are in the memory map. if the occr bit is set to one, rom is removed from the memory map, regardless of other control bits. 0 = configuration options are controlled by the config register.
motorola configuration and modes of operation m68hc11 3-14 reference manual 3.5.2 test-related control bits in the baud register the following register and paragraphs describe the two test-related control bits in the sci baud-rate (baud) control register. these bits, which are only accessible in the special modes, revert to zeros if the mode is changed to a normal mode. because no read path is implemented for these two bits, they always read zero, even after they are written to one in a special mode. tclr clear baud-rate timing chain can be written only while smod equals one. writing a one to this bit triggers a reset of the baud-rate counter chain. this bit always reads zero. rckb sci baud-rate clock test can be written only while smod equals one. writing a one to this bit enables a baud- rate clock test using the pd1 pin. when this baud-rate test function is enabled, the ex- clusive or of the sci receive clock (16 times the baud rate) and the sci transmit clock (one times the baud rate) is driven out the pd1 pin so it can be monitored by factory test equipment. this bit always reads zero. the other bits in this register are related to the asynchronous sci and are described in section 9 asynchronous serial communications interface . 3.5.3 special test mode the special test mode is primarily intended for motorola internal production testing; however, there are a few cases where the user can utilize the test mode. these spe- cial cases include programming the config register, programming calibration data into the eeprom, and development situations such as emulation and debug. since the mode control bits can be written in test mode, it is possible to come out of reset in special test mode, check the contents of the config register, and then switch to a normal operating mode to re-enable the automatic protection mechanisms. this trick is also useful for a first-time turn-on situation where the contents of the config reg- ister might not be known. except for these few limited cases, the MC68HC11a8 should not be in test mode in a users application. because the test mode overrides several automatic protection mechanisms or allows them to be overridden, there are risks associated with these modes of operation. for example, by default the cop and clock monitor are disabled in special modes. also in special modes, the $00 opcode is a legal opcode, which causes the address bus to become an uninterruptable 16-bit counter (useful for testing but a disaster in a real ap- plication). several of the test functions are included in this category. such risks must be weighed against whatever benefit is being derived from using special test or boot- strap operating mode. one important use of the test mode is to allow programming of the config register baud testing functions control register $102b bit 7 654321 bit 0 tclr 0 scp1 scp0 rckb scr2 scr1 scr0 reset: 00000*000
m68hc11 configuration and modes of operation motorola reference manual 3-15 and/or eeprom. since the reset and interrupt vectors are fetched from the users ex- ternal memory at the $bfc0C$bfff area, it is not necessary for the user to know if internal rom is on or off. even if the cop watchdog is enabled in the config regis- ter, there is no need to service it because cop resets are inhibited in special modes. the program needed to change eeprom data could be as simple as the program shown in example 3C1 (see 3.6 test and bootstrap mode applications ), which just reprograms the config register to a fixed value; it could be as complex as a complete monitor, similar to the buffalo monitor, which would allow interactive examination and modification of eeprom data. the test mode is useful in the debug phase of a project. in test mode, the data from reads of internal addresses can be seen on the external data bus. this function is called irv and is useful for debugging with a logic analyzer or bus state monitor. in normal operating modes, irv is disabled since it could interfere with external circuitry. for example, if an external 32-kbyte eprom were mapped at $8000C$ffff, it would overlap the internal eeprom from $b600C$b7ff. the easiest decode logic would be to select the external eprom when addr15 and r/ w are both high, which is perfect- ly legal and reasonable for the MC68HC11a8 operating in normal expanded mode. al- though the external eprom is selected for reads of the internal eeprom, the read data from the external data bus is ignored, and the cpu receives valid, internal ee- prom data. if the irv function were allowed in normal mode, this example would re- sult in a direct contention between the read data from the internal eeprom, which is driven out the data bus for visibility, and the read data from the external eprom. to overcome this contention, more complex decoding would be required for the external devices. a mass-produced product should not bear the cost of a debug feature; the more complex decoding belongs in the low-volume emulator tool where irv will be used. 3.5.4 special bootstrap mode when the mcu is reset in the special bootstrap mode, a small on-chip rom is enabled at address $bf40C$bfff. the reset vector is fetched from this bootstrap rom, and the mcu proceeds to execute the firmware in this rom. the program in this rom ini- tializes the on-chip sci system, checks for a security option, accepts a 256-byte pro- gram through the sci, and then jumps to the loaded program at address $0000 in the on-chip ram. there are almost no limitations on the programs that can be loaded and executed through the bootstrap process. while the mcu is operating in bootstrap mode, the mda control bit can be written; thus, it is possible to turn on the multiplexed expansion bus. this possibility makes the bootstrap mode useful in both single-chip and expanded systems. in some systems, it may be necessary to disable the bootstrap rom by writing a zero to the rboot con- trol bit to allow access to external devices in $bf40C$bfff. if the bootstrap rom is disabled, it is necessary for the user to externally provide reset and interrupt vectors at $bfc0C$bfff or switch the smod control bit back to zero so interrupt and reset vectors return to $ffc0C$ffff.
motorola configuration and modes of operation m68hc11 3-16 reference manual 3.5.4.1 loading programs in bootstrap mode this section describes the bootloader firmware in the standard MC68HC11a8. when the security mode is not specifically requested, it is disabled at the mask level so it will not be invoked accidentally. in these cases, the program steps, which check for secu- rity and optionally erase the eeprom and config register, are not included in the bootloader program. on some early production units before 1988, the security checks were included even on parts having the security mode disabled in the mask. also, the security feature was enabled in the mask of some parts where the security feature was not specifically requested. the bootloader rom program initializes the sci so that the receiver and transmitter are enabled and the baud rate is e clock/16/16 (7812 baud if e = 2 mhz). if the security feature is present and enabled, $ff is transmitted. the eeprom is then erased. if the erasure was unsuccessful, $ff is again transmitted, and erasure is attempted again. after successful erasure of eeprom, the ram is written over with $ff, and the con- fig register is erased. only after all of these operations are successful can the boot- loading process continue as if the part were never secured. if the mcu is not secured (or if the previous erase sequence has been completed), a break character is transmitted. for normal use of the bootloader, the user then sends an $ff character at a baud rate of either e clock/16/16 (7812 baud i fe=2 mhz) or e clock/16/13 (1200 baud if e = 2 mhz). this initial character is used to establish the baud rate for the rest of the transfer and is not echoed to the transmitter as the remain- ing characters are. the user next downloads 256 bytes of program data, which will be put into on-chip ram beginning at address $0000. if the program to be loaded is less than 256 bytes, dummy characters must be sent to make a total of 256 bytes. these 256 characters are echoed out the sci transmitter for the user to optionally verify that they were re- ceived correctly. when the bootloader program receives the 256th byte, a jump is ex- ecuted to location $0000, and the loaded program gains control. future m68hc11 family derivatives could have additional features in the bootloader program. one such feature is a variable-length download rather than the fixed-length, 256-byte download on the MC68HC11a8 version. this feature will probably be includ- ed on m68hc11 members that have more than 256 bytes of on-chip ram. the MC68HC11e9 version has 512 bytes of ram and includes a variable-length down- load. 3.5.4.2 executing user programs in bootstrap mode an often overlooked aspect of the bootstrap mode is that the bootloader firmware in the bootstrap rom executes after reset but before the users downloaded program be- gins. many users make the mistake of assuming all registers and i/o pins are still in their reset state when their downloaded program starts. actually, the bootloader firm- ware has made some significant changes to the reset state of the mcu in the course of its operation. because the sci receiver and transmitter have been enabled, the user must disable them if the pd0 or pd1 pins are to be used as general-purpose i/o pins. the port d wired-or mode (dwom) control bit in the spcr has been written to one
m68hc11 configuration and modes of operation motorola reference manual 3-17 so the port d outputs (especially pd1/txd) would operate as open-drain outputs dur- ing the download. this dwom bit must be written back to zero if the user wants any port d pins to act as push-pull outputs. because the bootstrap mode is a special mode, test-related functions are enabled. the disr control bit is a one, which disables the cop watchdog and clock monitor functions. as long as the smod control bit is a one, all reset and interrupt vectors are located in $bfc0C$bfff rather than $ffxx. a users program may have to change some of these control bits. special attention should be paid to the circuitry connected to the pd1/txd pin if the bootstrap mode variation is used. since the bootloader firmware enables the sci transmitter, the pd1 pin is forced to operate as an output. to minimize limitations on external circuitry on the pd1 pin, port d is also configured for wired-or operation to make it look like an open-collector-type output during downloading. most users will use the pd1/txd pin as a serial data output line; therefore, no conflict will occur between the bootstrap use of pd1 and the users use of this pin. if the application uses the pd1 pin as an input to detect a switch or contact closure, there is still no conflict, although the user could not use the verify feature of the bootloader program if the pd1 pin hap- pened to be driven low during the download. a downloaded program can jump back to the beginning of the bootstrap rom, causing a new program segment to be serially downloaded. the downloaded program might also contain a routine to read information into the mcu over the spi interface or from a parallel i/o port. the loaded program can even turn on the multiplexed expansion bus to gain access to external memory or peripheral devices. users are limited only by their imagination. 3.5.4.3 using interrupts in bootstrap mode the reset and interrupt vectors for the bootstrap mode are located in the bootstrap rom at $bfc0C$bfff. although this rom is mask programmed, it is impossible to know in advance where a users service routines will be located. to allow users to use their own service-routine addresses, a system of pseudo-vectors is included for boot- strap mode. specific ram addresses are coded in the actual vector locations of the bootstrap rom (see table 3-3 ). these ram locations are called pseudo-vectors be- cause they can be used like vectors to direct control to interrupt service routines. each pseudo-vector is allowed three bytes of space, rather than the two bytes for normal vectors, because an explicit jump (jmp) opcode is needed to cause the desired jump to the users service-routine address. for example, to use the swi, a jump instruction to the users swi service routine would be placed in ram at addresses $00f4, $00f5, and $00f6. when an swi request is encountered, the registers are stacked, and the vector in the bootstrap rom passes control to $00f4, which, in turn, contains a jump instruction to the users swi service routine.
motorola configuration and modes of operation m68hc11 3-18 reference manual 3.5.4.4 bootloader firmware options the designers of the MC68HC11a8 anticipated the need for a practical way to force the mcu to jump directly into eeprom after a reset, but they wanted to avoid special modes that would make the part more difficult to understand. as a compromise, the bootloader firmware provides for this direct jump to eeprom. after initializing the sci and port d, the bootloader looks for the $ff character that will determine the baud rate for the download. if a break character is received at this point, instead of the $ff, an immediate jump to the start of eeprom ($b600) is executed. since the bootloader already transmits a break character, the user can tie the rxd and txd pins together and to a pull-up resistor, and then reset the part in special bootstrap mode. this procedure will cause a direct jump to eeprom at $b600. tying the rxd line low will not accomplish the same result because a high-to-low transition is required to in- dicate the beginning of a start bit (see section 9 asynchronous serial com- munications interface ). there is a small delay (a few milliseconds) between the reset and the start of the pro- gram in eeprom due to the time required for the sci preamble and break characters. the user should not be concerned about running out of time to access the time-pro- tected control bits because bootstrap mode is a special mode and the protections are overridden until the smod control bit is written to zero. consider the current state of sci and port d controls as well as the disr control bit in the test1 control register, which disables cop and clock monitor resets. it may be necessary for the program in eeprom to change these bits. the stack pointer is initialized as one of the first ac- tions in the eeprom program (good practice in almost all programs). it is advisable to initialize the illegal opcode pseudo-vector to help prevent program runaway in the event of an error in the eeprom program or a misread opcode. another bootloader firmware option allows a direct jump to the start of ram, but this feature is probably not very useful to the user since it assumes there is already a meaningful program in the internal ram at the time of reset. this option is invoked by sending a $55 character to the sci instead of the $ff or break characters previously table 3-3 bootstrap mode pseudo-vectors address vector name address vector name $00c4C$00c6 sci $00e5C$00e7 timer input capture 2 $00c7C$00c9 spi $00e8C$00ea timer input capture 1 $00caC$00cc pulse accumulator input edge $00ebC$00ed real-time interrupt $00cdC$00cf pulse accumulator overflow $00eeC$00fd irq $00d0C$00d2 timer overflow $00f1C$00f3 xirq $00d3C$00d5 timer output compare 5 $00f4C$00f6 swi $00d6C$00d8 timer output compare 4 $00f7C$00f9 illegal opcode $00d9C$00db timer output compare 3 $00faC$00fc cop fail $00dcC$00de timer output compare 2 $00fdC$00ff clock monitor fail $00dfC$00e1 timer output compare 1 $bf40 reset (bootloader start) $00e2C$00e4 timer input capture 3
m68hc11 configuration and modes of operation motorola reference manual 3-19 described. this $55 character can only use the e clock/16/16 (7812 baud fo re=2 mhz) rate since it takes the place of the $ff character, which could have changed the baud rate. this feature allows for testing the mcu for proper single-chip mode opera- tion when the e-clock frequency is beyond the capability of the multiplexed expansion bus. test equipment can reset the mcu in special test mode (at a legal expansion bus frequency) and parallel load a program into ram. the tester can then reset the mcu in bootstrap mode (at a higher clock frequency) and serially send the $55 character to cause a jump to the start of ram. this procedure takes significantly less time than us- ing the normal bootloading procedure to serially load 256 characters. since the pro- gram segments are limited in size by the amount of on-chip ram, the time required to load enough program segments to fully test the mcu would make such testing too ex- pensive for all but a very few applications. 3.6 test and bootstrap mode applications most users are familiar with the uses for normal operating modes, but the special test and special bootstrap modes may be new. in this section, an example is presented to stimulate the users imagination. after examining this example, some users will think of ways these special mode variations can help in their applications. example 3C1: programming config (uses special test mode) this example demonstrates how the special test mode can be used to program the eeprom-based config register. current versions of the m68hc11 family require the mcu to be in one of two special modes to program the config register. there are several reasons why a user might want to change the config register. suppose the user has an mc68hc811e2 and would like to experiment with it in an expanded system such as an MC68HC11evb evaluation board. as shipped from mo- torola, the mc68hc811e2 part is not compatible with the memory map of the evb. the eeprom must be disabled by programming the eeon bit to zero, or the upper four bits of config must be changed to relocate the eeprom away from evb re- sources. suppose the user is finished with initial debugging and wants to enable the cop watchdog system by programming the nocop bit in config to zero. perhaps the config registers in some of the users parts have been corrupted during initial experimentation. some users forget to control reset during power transitions; thus, the config register could be corrupted due to program runaway when v dd is too low to allow proper operation. when this runaway happens, the part is not defective; it needs to have the config register changed back to the proper value. the schematic diagram shown in figure 3-1 is a relatively simple expanded-mode system that can be operated in special test mode. by removing the jumper that pulls modb low, this board can also be used in normal expanded mode. an interesting fea- ture of this system is that the external eprom appears in the memory map at $a000C $bfff and again at $e000C$ffff because address line addr14 is left out of the ad- dress decode. this feature makes reset vectors in the highest locations of the eprom appear the same to the mcu whether the mcu is reset in special test mode or normal expanded mode with the internal rom disabled. several subtle benefits to this feature are evident. first, it means no decode changes are needed to alternate between nor-
motorola configuration and modes of operation m68hc11 3-20 reference manual mal mode and special test operation of the board. in fact, after a reset in special test mode, software can change to normal expanded mode, and the reset and interrupt vectors are still available in the external eprom. if the internal 8 kbyte rom has a useful program in it (and internal rom is enabled), the external eprom can be used for additional program memory. of course, when the cpu reads an internal rom ad- dress, it sees valid internal rom data even though the external data bus has data from the external eprom. as long as the irv function is not enabled, there is no conflict between the internal 8 kbytes rom and the external eprom. in example 3C1, the program shown in figure 3-3 is programmed into the external 2764-type eprom. when the board is turned on, this small program reads the eight- part switch that is wired to the port e pins. if the config register is different, it is re- programmed to match the switches. because the eeprom is subject to wear-out (af- ter thousands of write-erase cycles), it should not be erased and reprogrammed unless it is incorrect. since this program is intended to be very simple, it does not check to see if the change was successful. this program could be modified to include the ability to check the results. the security feature offers some challenges. for example, if security mode is being enabled, it is not possible to verify the config value in this setup. a reset is required to get the config value transferred into the readable working register, and the part can only be reset in single-chip modes after security is enabled. if the secured part is reset while modb is low, it comes up in special bootstrap mode (moda pin is ignored due to se- curity). when reset in bootstrap mode, the eeprom and config register are auto- matically erased, which is self-defeating. presumably, a user has a meaningful program in internal rom before the security bit is finally enabled, which provides for orderly program execution in normal single-chip mode. the user then verifies that se- curity is enabled by a checking function in that internal software. another way to check for security is to attempt to reset the part in normal expanded mode. if security is not enabled, the as/stra pin acts as an address strobe that clocks at the e-clock fre- quency even while reset is still low (part does not have to be out of reset to check for security). if security is not activated, the as/stra pin acts as the strobe a high- impedance input.
m68hc11 configuration and modes of operation motorola reference manual 3-21 figure 3-1 schematic for figure 3-3 (sheet 1 of 2) v dd + 4.7k mc34064 v dd reset v dd gnd in 1k 1 m f v dd 10m 8.0 mhz 18 pf 18 pf v dd 4.7k 4.7k 0.01 m f 10 m f system power cut jumper for normal mode reset xirq irq v v rh rl moda/lir v stby modb/v dd v ss extal xtal MC68HC11a8 pa0/ic3 pa1/ic2 pa2/ic0 pa3/oc5/oc1 pa4/oc4/oc1 pa5/oc3/oc1 pa6/oc2/oc1 pa7/pai/oc1 a8 a9 a10 a11 a12 a13 a14 a15 pe4/an4 pe5/an5 pe6/an6 pd0/rxd pd1/txd pd2/miso pd3/mosi pd4/sck pd5/ss pe7/an7 pe0/an0 pe1/an1 pe2/an2 pe3/an3 v dd 10k typ e 4.7k 4.7k 1 m f as ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 r/ w 10k typ a8 a9 a10 a11 a12 a13 a15 pe4 pe5 pe6 pe7 pe0 pe1 pe2 pe3 e as ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 r/ w
motorola configuration and modes of operation m68hc11 3-22 reference manual figure 3-2 schematic for figure 3-3 (sheet 2 of 2) data bus address bus d0 d1 d2 d3 d4 d5 d6 d7 a0 a1 a2 a3 a4 a5 a6 a7 d0 d1 d2 d3 d4 d5 d6 d7 a8 a9 a10 a11 a12 8k x 8 eprom a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 oe q0 q1 q2 q3 q4 q5 q6 q7 le d0 d1 d2 d3 d4 d5 d6 d7 74hc373 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 d0 d1 d2 d3 d4 d5 d6 d7 e r/ w dip switch cs oe d0 d1 d2 d3 d4 d5 d6 d7 10k typ 10k typ hc00 hc00 a13 a15 cs oe v dd v dd a8 a9 a10 a11 a12 a13 a15 pe4 pe5 pe6 pe7 pe0 pe1 pe2 pe3 e as ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 r/w
m68hc11 configuration and modes of operation motorola reference manual 3-23 *********************************************************************** ************************************************************************* ***** * example 3C1 65 bytes total * * * * this example program uses the hardware setup in figure 3C1 in test * * mode. after reset the config register is checked against port e. * * if it is different, config is erased and reprogrammed to the port e * * value. $30 is written to port a and the program ends. * ************************************************************************* ***** org $a000 start of external eprom ex31a lds #$00ff establish top of stack bsr dly10 allow charge pump to stabilize ldaa $100a read port e dip switches anda #$0f mask off upper 4 bits (not implemented on a8) cmpa $103f see if config is same beq nowok if already ok * not ok so first erase config ldab #$06 bulk erase, and eelat on stab $103b write to pprog register staa $103f write to config address (any data) incb to $07 - turns on eepgm bit stab $103b write to pprog register bsr dly10 delay 10 ms for erase to complete clr $103b turn off charge pump (eepgm to 0) * now reprogram config with data from port e (still in a-reg) ldab #$02 turn on eelat stab $103b write to pprog register staa $103f write port e data to config address incb to $03 - turns on eepgm bit stab $103b write to pprog register bsr dly10 delay 10 ms for erase to complete clr $103b turn off charge pump (eepgm to 0) * programming complete but you cant check results till next reset nowok lda #$30 staa $1000 you are done (check with scope) bra * branch to self (hangs till pwr off or rst) * * pr0gram end subroutines follow * *** * dly10 - subroutine to delay l0ms (for e=2mhz) *** dly10 pshx save x (not required in this ex i just do) ldx #$0d06 3334 6~ * 500ns/~ = l0ms dloop dex [3] in []s is cycles for that instruc bne dloop [3] cont. for 3334 times (loop time = 6~) pulx recover x value rts **return** * * establish a reset vector * org $bffe reset fdb $a000 point to start of program figure 3-3 program to check/change config
motorola configuration and modes of operation m68hc11 3-24 reference manual
m68hc11 on-chip memory motorola reference manual 4-1 section 4 on-chip memory the MC68HC11a8 includes on-chip random-access memory (ram), read-only mem- ory (rom), and electrically erasable programmable rom (eeprom) memories. the on-chip ram is a fully static read-write memory used for storage of variable and tem- porary information. the MC68HC11a8 has 256 bytes of ram; whereas other mem- bers of the m68hc11 family include more or less ram (MC68HC11e9 has 512 bytes of ram and MC68HC11d3 has 192 bytes of ram). members of the m68hc11 family include various amounts of on-chip mask-programmed rom. the MC68HC11a8 has 8 kbytes of user rom, the MC68HC11e9 has 12 kbytes, and the MC68HC11d3 has 4 kbytes. this rom is used for storage of user program instructions and fixed data. some members of the m68hc11 family have this internal rom disabled, and the user programs reside in external memories. the last major memory system on the m68hc11 is the eeprom. the MC68HC11a8 includes 512 bytes of eeprom; whereas other members of the m68hc11 family include as much as 8.5 kbytes of ee- prom. data can be programmed into the eeprom or erased from the eeprom un- der software control. no power supplies other than the normal v dd (5 vdc) supply are needed for programming or erasure of the 512 bytes of on-chip eeprom in the MC68HC11a8. no power supplies are required to maintain the contents of this mem- ory. this memory is commonly used for semipermanent information such as calibra- tion tables, personality data, or product history information. the eeprom can also be used for program memory; furthermore, the non-volatile nature of this eeprom sup- ports programs that can adapt to changing conditions. 4.1 rom the primary use for on-chip rom is to hold the users application program instructions. since these instructions are programmed into the microcontroller unit (mcu) when it is manufactured, they cannot be changed. a user develops the application program and debugs it before ordering production mcus. the user places an order for produc- tion units with the pattern of instructions and data to be programmed into the on-chip rom. motorola then translates this pattern into a photographic mask to be used during processing of silicon wafers. motorola then produces a small batch of these parts and returns them to the customer for verification. these units are called rom verification units (rvus). after customer approval of these rvus, motorola begins full production of these customized mcus. the rvus, processed on a quick turnaround basis, are not tested to environmental extremes because their sole purpose is to demonstrate that the customer-requested rom pattern was properly implemented. the on-chip program rom can be disabled by an eeprom-based control bit in the configuration control (config) register. when the program rom is disabled, it uses up no space in the 64-kbyte memory space, and an external memory is used for pro- gram instructions. rom-less versions of the m68hc11 family, such as the MC68HC11a1, actually have on-chip rom, but the rom is disabled by the enable on-
motorola on-chip memory m68hc11 4-2 reference manual chip rom (romon) control bit equals zero in the config register. the MC68HC11a8 actually has two separate on-chip rom memories the 8-kbyte user rom, which is available for user-defined programs, and a separate 192-byte rom, called the bootloader rom. this bootloader rom controls the bootstrap loading process of the special bootstrap mode. in normal modes of operation, the bootloader rom is disabled and uses no space in the 64-kbyte address space of the mcu. dur- ing expanded test mode, the bootloader rom can be enabled for testing but is not in the memory map after a reset until/unless the test program software enables it. in spe- cial bootstrap mode, the bootloader rom is enabled at $bf40C$bfff by default out of reset, and the reset vector in this rom at $bffe,bfff vectors to the bootloader program in this rom. the bootloader program is also involved with the security feature that allows a user to protect the contents of eeprom and ram from being read by software pirates. when the security option is enabled, the mcu can only be reset in normal single-chip mode or special bootstrap mode. in normal single-chip mode, the reset vector is located in the on-chip 8-kbyte rom, and the users program controls all program actions. since there are no external address or data buses, a pirate could not see what is in the in- ternal eeprom or ram memories. in special bootstrap mode, the reset vector is lo- cated in the on-chip bootloader rom, and the bootloader program is in control. the bootloader program checks the security enable control bit before proceeding to the program downloading step. if security is enabled, the entire eeprom and ram are erased before downloading continues. after the eeprom and ram have been erased and verified, the config register (which contains the security enable control bit) is erased, and downloading can proceed. for additional information about the config register and security option, refer to 3.2 eeprom-based config regis- ter . section 3 configuration and modes of operation also includes ad- ditional details about modes of operation. 4.2 ram this subsection discusses the on-chip ram of the MC68HC11a8. this 256-byte ram can be mapped to the beginning of any 4-kbyte block in the 64-kbyte address space. the methods and reasons for this remapping are discussed; two methods of ram standby are also discussed. 4.2.1 remapping using the init register by default, the on-chip ram is located in the first 256 locations ($0000C$00ff) of the 64-kbyte memory map. in many (but not all) cases, this location is good for the on-chip ram. the first 256 locations in memory are accessible using the direct addressing mode, which assumes the upper byte of the 16-bit address is $00. since the direct ad- dressing mode can address these locations with a one-byte address rather than a two- byte address, each such instruction saves a byte of program memory space and a cy- cle of execution time compared to the same instruction using expanded addressing mode. depending upon the application, maximum efficiency can be achieved by hav- ing ram, i/o registers, or both in this premium address space.
m68hc11 on-chip memory motorola reference manual 4-3 the position of ram in the 64-kbyte address space is controlled by the ram and i/o mapping (init) register. the upper four bits of init (ram[3:0]) specify the upper four bits of the 16-bit ram addresses. at reset, the ram[3:0] bits are forced to zero so the ram is initially located at $0000C$00ff. by writing some other value to the init reg- ister, the ram can be relocated to the beginning of any 4-kbyte page in the 64-kbyte address space. in normal operating modes, the init resister is protected so that it can only be changed within the first 64 cycles after reset. for more detailed information about the init register, see 3.3.1 ram and i/o mapping register (init) . 4.2.2 ram standby there are several purposes for a ram standby function. in battery operated systems, the ram standby function provides a way to conserve limited battery power during times of mcu inactivity, which increases the effective time the system can operate without battery charging or replacement. in systems using a municipal electric system as the primary source of power, operating power is not usually a major issue, but pow- er interruptions can be. there may be enough energy stored in regulator filter capac- itors to allow a system to operate for some period of time after primary power is lost. the system current drain determines how long the stored energy can maintain the sys- tem. by detecting the loss of primary power and changing to a low-power standby mode, the mcu system can be maintained through longer power interruptions. after the interruption, the system can decide whether to continue operation or to perform a complete reset initialization. in other municipal-powered systems, it may be useful to maintain a limited amount of information during very long interruptions of primary pow- er. in such cases, a separate standby power source based on a battery could be used to maintain the contents of ram while the system is non-operational. the on-chip ram of the m68hc11 family is fully static; there are two ways ram con- tents can be maintained while reducing system power consumption to very low levels. the easiest method for low-power ram standby is the software-based stop mode. the alternate method uses the modb/v stby pin for standby power in a mostly hard- ware approach. since the entire mcu, including ram, is fully static, there is no mini- mum oscillator clock frequency. in complementary metal oxide semiconductor (cmos) integrated circuits, power supply current is directly proportional to operating frequency; thus, only very small leakage currents exist when clocks are stopped. this is the basis for the stop method of ram standby. when the mcu is stopped, all cpu registers, control and i/o registers, and all ram contents remain unchanged as long as v dd is present. i dd for the mcu is reduced to a few microamps when mcu clocks are stopped. in some systems, there may be other circuitry powered from v dd that cannot be easily placed in a low-power standby mode. in these systems, v dd must be turned off to re- duce system power drain. the modb/v stby method of ram standby allows v dd to be removed without losing the contents of on-chip ram. this method is more hard- ware intensive because it involves a second power supply and associated problems. in cmos systems, it is possible to power an integrated circuit through an i/o pin be- cause, on some i/o pins, there is an inherent diode between the pin and the internal v dd . in some cmos systems, even the sequencing of power supplies is critical, which
motorola on-chip memory m68hc11 4-4 reference manual implies using caution whenever there is more than one power supply in a system. al- though the sequencing of v dd relative to modb/v stby is not important on the MC68HC11a8 itself, the sequencing may be important to any other cmos device in the system exposed to both v dd and v stby . several i/o pins on the mcu should not have voltage on them while v dd is off. any pin having the source or drain node of a p-channel device in the on-chip circuitry con- nected to this pin has an inherent diode to v dd . if such a pin were connected to a sig- nal powered by v stby rather than v dd , the entire v dd network would be powered by v stby through the inherent diode. powering the v dd network in this way may result in unexpected operation of the system and definitely results in more load on the v stby supply than expected. 4.3 eeprom the MC68HC11a8 was the first mcu to include cmos eeprom. this 512-byte ee- prom memory can be used in the same ways rom would be used, but some inter- esting possibilities arise that are not possible with rom or ram memories. a simple example is to store a unique serial number in the eeprom of each finished product. once information is programmed into the on-chip eeprom, it remains unchanged even if v dd power is removed indefinitely. unlike information in rom, information in eeprom can be erased or reprogrammed under software control. since eeprom programming and erasure operations use an on-chip charge pump driven by v dd ,no special power supplies are needed. this subsection describes the operation of the eeprom on the MC68HC11a8 and explores some of its applications. in addition to the 512 bytes of user eeprom on the MC68HC11a8, there is another eeprom byte (config register) controlling some basic features of the mcu. the config register and mechanism are described in de- tail in 3.2 eeprom-based config register , but some aspects of the eeprom en- able bit (eeon), and the security mode disable bit (nosec) will be discussed in terms of how they relate to eeprom. the m68hc11 family of mcus includes members with various amounts of eeprom. the mc68hc811a8 (emulator for the basic MC68HC11a8) has 8.5 kbytes of ee- prom. the principles presented here apply specifically to the original MC68HC11a8. some details of eeprom operation may vary slightly for other members of the m68hc11 family; however, the basic concepts presented here can be extended to explain the operation of these other members. 4.3.1 logical and physical organization the logical organization of the 512-byte eeprom is important for identification of rows when using the row-erase feature. the physical organization may be useful in isolating problems in rare cases. although some family members (e.g., mc68hc811e2) allow remapping of the on- chip eeprom, the 512-byte eeprom in the MC68HC11a8 is fixed at locations $b600C$b7ff. this 512-byte block is logically arranged into 32 rows of 16 bytes each. the first row occupies the locations $b600C$b60f, the second row occupies $b610C
m68hc11 on-chip memory motorola reference manual 4-5 $b61f, etc. eeprom locations can be erased individually (byte erase), in rows of 16 bytes each (row erase), or all 512 bytes at once (bulk erase). the config byte is sep- arate from this 512-byte block. special restrictions apply to erasure of the config eeprom byte. figure 4-1 shows the topological organization of the 512 bytes of ee- prom in the MC68HC11a8. figure 4-2 shows the topological arrangement of bits within a byte of eeprom. figure 4-1 topological arrangement of eeprom bytes (MC68HC11a8) figure 4-2 topological arrangement of bits in an eeprom byte 4.3.2 basic operation of the eeprom the following paragraphs briefly describe how the eeprom operates. figure 4-3 ,a condensed schematic of the eeprom array, provides insight into the operation of the eeprom system and illustrates the complexity of a byte-erasable eeprom. each byte in the eeprom array consists of 17 transistors, eight floating-gate transistors, a select transistor for each floating-gate transistor, and a byte-select transistor. in com- parison, an ultraviolet erasable eprom byte requires only the eight floating-gate tran- b7e1 b7e0 array left half b62f b620 b64f b640 b66f b660 b68f b680 b6af b6a0 b6cf b6c0 b6ef b6e0 b70f b700 b72f b720 b74f b740 b76f b760 b78f b780 b7af b7a0 b7cf b7c0 b60f b60e b601 b600 b7ef b7ee b7fe b7ff array right half b630 b63f b650 b65f b670 b67f b690 b69f b6b0 b6bf b6d0 b6df b6f0 b6ff b710 b71f b730 b73f b750 b75f b770 b77f b790 b79f b7b0 b7bf b7d0 b7df b610 b611 b61e b61f b7f0 b7f1 config row column decoders and sense amps row decoders and drivers charge pump rom array for left half for right half b601 b600 b610 b611 bit 7 bit 7 bit 7 bit 7 bit 0 bit 0 6 54 3 2 1 654321 6 5 65
motorola on-chip memory m68hc11 4-6 reference manual sistors. figure 4-4 shows an eeprom bit with important features and nodes labeled. these terms will be used in the following explanation of basic eeprom operations. figure 4-5 , figure 4-6 , and figure 4-7 show an eeprom byte being erased, programmed, and read, respectively. the floating-gate transistor is the storage element in the ee- prom cell. since the floating gate is isolated by thin oxide layers, any charge on this gate remains indefinitely unless a large enough field is created, as in programming and erase modes. when a large enough field is present, fowler-nordheim electron tunneling allows charge to be transferred to or from the floating gate, depending on the polarity of the field. in the following discussion, v dd is nominally 5 v and v pp is about 20 v. in the MC68HC11a8, v pp is developed from v dd with an on-chip charge pump; thus, no external high voltages are required. figure 4-3 condensed schematic of eeprom array 1 byte row (0) row (n) col (0) col (n) v i/o (7) i/o (0) erase array ground
m68hc11 on-chip memory motorola reference manual 4-7 figure 4-4 eeprom cell terminology figure 4-5 erasing an eeprom byte in erase mode (see figure 4-5 ), the array ground is connected to v ss . the row and column selects cause the control gates of the byte(s) being erased to be connected to v pp . other bytes in the array that are not being erased would have their control gates connected to an undriven logic zero. the bit-select devices are all turned on by v pp on the word lines; however, the drains of the bit-select devices are high impedance. thus, the drains of the floating-gate transistors are effectively floating. the high volt- age on the control gate of the floating-gate transistor is capacitively coupled onto the floating gate. the large field between the floating gate and the substrate results in electron tunneling from the substrate to the floating gate. after erasure, the floating gate has a negative charge, which keeps the floating-gate transistor turned off during reads. if leakage in the floating-gate transistor caused the negative charge to leak off so that there was no charge on the floating gate, the bit would still read back as one. this fact implies that long-term retention errors cannot cause a logic-one bit to deteri- orate to a logic zero. figure 4-6 shows an eeprom byte being programmed to the value $55 (0101 0101) array ground bit line bit-select device floating-gate device row select control gate floating gate s d g array ground 7 v pp not driven 654 3210 v tn v ss v pp
motorola on-chip memory m68hc11 4-8 reference manual to demonstrate the effect of programming both ones and zeros. since the erased state of an eeprom bit is one, programming a one is the same as doing nothing. during programming, the array ground is not driven. the control gates of the byte to be pro- grammed are driven to zero through the row-select and column-select path. control gates for bytes not being programmed will be high impedance because the column- select and/or row-select device will be off. the bit-select devices are turned on hard because the row select, for the row containing the byte being programmed, is driven to v pp . the bit lines are driven to v dd for bits not being programmed (ones) and to v pp for bits being programmed (zeros). for bits not being programmed (ones), the drain of the floating-gate transistor is at v dd , and the control gate is at v ss . this configuration does not result in a large enough field for tunneling to occur; thus, no charge transfer occurs. figure 4-6 programming an eeprom byte for bits being programmed (zeros), the drains of the floating-gate transistors are at v pp Cv tn (because of the drain-to-source threshold voltage drop across the bit-select device), and the control gate is at v ss . this configuration results in a large enough field so electrons can tunnel from the floating gate to the drain region of the floating-gate transistor. since the floating gate of a programmed bit has a positive charge, the float- ing-gate transistor will conduct during reads. figure 4-7 shows an eeprom byte being read. during a read operation, the bit lines are precharged to one. column selects enable the bit lines from the byte being read to the sense amp inputs. the row select for the row containing the byte being read is driven to v dd to enable the bit-select devices. the array ground is connected to v ss . the floating gate devices of programmed bits conduct and pull the corresponding bit lines to zero. the floating-gate devices of bits not programmed do not conduct; there- fore, the corresponding bit lines remain at the precharged level and read as ones. ee- prom operations are actually much more complicated than this discussion suggests, but the following general statements may be useful to designers using the eeprom. 1) since no high voltages are present during read operations, no degradation of data array ground 7 v pp 654 3210 v ss (not driven) 0101 0101 v pp v dd v pp v dd v pp v dd v pp v dd
m68hc11 on-chip memory motorola reference manual 4-9 can result from repeated read operations. 2) erase operations normally take less time than programming operations. 3) the most common eeprom failure (write ones) is an unintended bit change from one to zero during programming of $ff data. this fail- ure occurs during endurance testing as the part approaches wear-out (typically after tens of thousands of write-erase cycles). 4) retention failures result in programmed zeros reverting to ones due to leakage of the floating-gate charge. 5) ones never re- vert to zeros without an explicit programming operation (though the programming op- eration need not involve any zeros in the pattern being programmed). figure 4-7 reading an eeprom byte eeprom programming and erasure involve the movement of charge through a thin oxide layer. this charge movement requires a relatively large field to be present for a significant length of time (milliseconds). noise is not likely to cause individual bits to change state. most failures of the eeprom involve breakdowns due to the relatively high voltages or to an oxide degradation phenomenon (trapped charge). after many cycles of programming and erasure, charge may become trapped in the thin oxide lay- ers isolating the floating gate. this trapped charge causes programming and erase op- erations to take longer as the amount of trapped charge increases. when the cell fails to program to zero in the allotted time, it is worn out. in many cases, these bits can still be programmed and erased provided the program and erase times are increased. the useful life of an eeprom byte cannot be extended very far by extending the program- ming time because a worn bit exhibits a reduced ability to retain valid zeros for very long time periods. 4.3.3 systems operating below 2-mhz bus speed (e clock) the on-chip charge pump that generates v pp from v dd uses mos capacitors, which are relatively small in value. the efficiency of this charge pump and its drive capability are affected by the level of v dd and the frequency of the driving clock. the load de- pends on the number of bits being programmed or erased and capacitances in the ee- prom array. effective array load capacitances are influenced to some degree by the data in the array. the clock source driving the charge pump is software selectable. when the clock se- array ground 7 v dd 654 3210 v ss v ss precharge then sense
motorola on-chip memory m68hc11 4-10 reference manual lect (csel) control bit in the option register is zero, the e clock is used; when csel is one, an on-chip resistor-capacitor (rc) oscillator is used. the frequency of this on- chip rc oscillator is about 2.5 mhz but varies with processing. the recommended programming and erase time is 10 ms when v dd is 5 vdc 10 per- cent and the e clock is 2 mhz. if the e clock is 1 mhz or less, the csel bit should be written to one to enable the on-chip rc oscillator to drive the v pp charge pump. for an e clock between 1 and 2 mhz, the programming and erase times can be increased to 20 ms, or the rc oscillator can be selected. experimentation has shown the ee- prom is programmable with v dd equal to 3 vdc and csel equals one to enable the on-chip rc clock. csel also enables a separate rc oscillator associated with the a/d converter sys- tem. the e-clock frequency (where switchover to csel equals one is recommended) is lower for the a/d than it is for eeprom operations. in the a/d system, switching to csel equals one can increase conversion errors; thus, it is better to perform a/d con- versions with csel equals zero. in some applications, it is worthwhile to switch csel on and off, depending on whether a/d or eeprom programming/erase operations are occurring. refer to 12.2.2 a/d charge pump and resistor-capacitor (rc) oscilla- tor for additional information. 4.3.4 eeprom programming register (pprog) the pprog register controls programming and erasure of the on-chip eeprom. the pprog register may be read or written at any time, but programming and erase se- quences are strictly controlled by logic to prevent unintentional changes to eeprom data. in the MC68HC11a8, the config register eeprom location cannot be pro- grammed or erased unless the mcu is operating in special test or special bootstrap mode. the v pp power supply voltage is not enabled to the eeprom array until all se- quence requirements are met for a programming or erase operation. the required se- quence consists of the following steps: 1) write to pprog with eeprom latch control (eelat) bit equals one and eeprom programming voltage enable (eepgm) bit equals zero; 2) write to a valid eeprom location or the config address; 3) write to pprog with eelat and eepgm bits equal one. hardware logic enforces this se- quence by imposing the following restrictions. if an attempt is made to change both eelat and eepgm to ones with the same write operation, neither bit is set (enforces step 1). writes to eeprom addresses are inhibited while eepgm is one, which pre- vents two kinds of errors. first, step 2 must be performed before step 3, or no ee- prom changes will occur. second, a write to a different eeprom location is prevented while a programming or erase operation is in progress. in some members of the m68hc11 family, there is a block protection mechanism that can inhibit programming and erasure of the config register or selected areas of ee- prom. after reset, these block protect control bits (in a block protect (bprot) regis- ter) are set to inhibit eeprom changes. a user can write these bits to zero to enable programming and erase operations, but this write must be performed within 64 cycles after reset. the user may write these bits back to one at any time to inhibit further ee- prom changes. once this protection is re-enabled, it remains in effect until another reset. there is no bprot register in the MC68HC11a8.
m68hc11 on-chip memory motorola reference manual 4-11 the following register and paragraphs describe the bits in the pprog control register. odd program odd rows in half the eeprom array even program even rows in half the eeprom array these two bits are used only during factory testing of the eeprom. to program all bytes in the odd (even) rows on one side of the eeprom array with the same data in a single programming operation, set the odd (even) and eelat bits to ones, write to an eeprom location in an odd (even) row, and then set the eepgm bit. since the onchip v pp charge pump does not have enough drive to perform this bulk program- ming operation, an external 20-v current-limited supply must be connected to the ex- ternal eeprom voltage source ( irq/v ppbulk ) pin. the intended purpose of this function is to allow the entire eeprom array to be filled with a checkerboard pattern in only four programming operations. this feature is not intended for customer use since the function serves no practical purpose other than product testing. byte byte/other eeprom erase mode row row/all eeprom erase mode these two bits specify the type of erase operation that is to be performed. these bits have no meaning when the erase bit is clear. the following table shows the relation- ship between the state of these bits and the type of erase operation that will be per- formed: erase erase/normal control of eeprom 0 = normal read or program mode 1 = erase mode eelat eeprom latch control when this bit is zero, the eeprom acts as a rom in the mcu memory map. when eelat is one, the eeprom acts as if it has been removed from the memory map and placed into a programming socket. latches on the address and data lines to the eeprom array are enabled to capture data and address information needed during program or erase operations. while eelat is one, the eeprom cannot be read, which implies a software routine that programs or erases eeprom cannot be execut- ed from that same eeprom. the operation of eelat also implies that programs that access data from the eeprom must not be executed while an eeprom location is being programmed or erased. pprog eeprom programming register $103b bit 7 654321 bit 0 odd even 0 byte row erase eelat eepgm reset: 00000000 byte row type of erase 0 0 bulk erase (all 512 bytes) 0 1 row erase (16-byte row) 1 0 byte erase 1 1 byte erase
motorola on-chip memory m68hc11 4-12 reference manual eepgm eeprom programming voltage enable this control bit enables the v pp power supply to the eeprom logic for programming and erase operations. when eepgm is zero, v pp is off; when eepgm is one, v pp is on. a logic interlock mechanism prevents setting this bit unless eelat was earlier written to one. 4.3.5 programming/erasing procedures the following discussion and program segments demonstrate the various program- ming and erase operations that can be performed on eeprom locations. these pro- gram segments are intended to be simple, straightforward examples of the sequences needed for basic program and erase operations. there are no special restrictions on the addressing modes used, and bit manipulation instructions may be used. other op- erations can be performed during programming and erasure provided these opera- tions do not include reads from the eeprom (the eeprom is disconnected from the read data bus during program and erase operations). the subroutine (dly10) used in these program segments is not shown but can be any set of instructions that takes 10 ms. if several bytes of eeprom are to be programmed, the eelat bit can be left at one for the entire block. after each byte is programmed, eepgm is written to zero and ee- lat is left at one. the next eeprom location is then written, and the eepgm bit is written back to one to execute the programming request. 4.3.5.1 programming during eeprom programming, the row and byte bits are not used. if the e-clock frequency is less than 2 mhz, the programming time may need to be increased, or the csel bit in the option register may have to be set to enable an on-chip rc oscillator to drive the v pp charge pump. since programming can only change ones to zeros in the eeprom, it is sometimes necessary to erase a byte to $ff in a separate opera- tion before programming it to a new value. the following programming segment dem- onstrates how to program an eeprom byte: * on entry, a = data to be programmed and x = an eeprom address " " prog ldab #$02 stab $103b set eelat bit (eepgm=0) staa 0,x store data to eeprom address ldab #$03 stab $103b set eepgm bit (eelat=1) jsr dly10 delay 10 ms clr $103b turn off high voltage & set to read mode " " 4.3.5.2 bulk erase the following program segment demonstrates how to bulk erase the 512-byte eeprom. the config register is not affected in this example.
m68hc11 on-chip memory motorola reference manual 4-13 " " bulke ldab #$06 stab $103b set to bulk erase mode stab $b600 write any data to any eeprom address ldab #$07 stab $103b turn on programming voltage jsr dly10 delay 10 ms clr $103b turn off high voltage & set to read mode " " 4.3.5.3 row erase the following example demonstrates the row-erase function. a row is 16 bytes ($b600Cb60f, $b610Cb61f ... $b7f0Cb7ff). when large sections of eeprom are to be erased, this type erase operation saves time compared to byte erase. * on entry, x=any address in row to be erased " " rowe ldab #$0e stab $103b set to row erase mode stab 0,x write any data to any address in row ldab #$0f stab $103b turn on high voltage jsr dly10 delay 10 ms clr $103b turn off high voltage & set to read mode " " 4.3.5.4 byte erase the following program segment demonstrates how to erase a single byte of eeprom. * on entry, x=any address of byte to be erased " " bytee ldab #$16 stab $103b set to byte erase mode stab 0,x write any data to address to be erased ldab #$17 stab $103b turn on high voltage jsr dly10 delay 10 ms clr $103b turn off high voltage & set to read mode " " 4.3.5.5 config register the following program segment shows how to program the config register in the MC68HC11a8 to a new value. the config byte can only be erased with the bulk- erase method on the original MC68HC11a8; however, some new members of the m68hc11 family allow the config byte to be byte erased. if any question arises about which members can use byte erase, refer to the technical summary for that member. it is possible to program additional bits in config to zero without erasing
motorola on-chip memory m68hc11 4-14 reference manual the location first; however, it is better to perform an erase first as shown in this example and explained in 4.4 eeprom application information . * on entry, a-data to be programmed into config " " cnfch ldab #$06 stab $103b set to bulk erase mode stab $103f write any data to config address ldab #$07 stab $103b turn on programming voltage jsr dly10 delay 10 ms ldab #$02 stab $103b turn off eepgm, leave eelat on staa $103f store new config data ldab #$03 stab $103b set eepgm bit (eelat-1) jsr dly10 delay 10 ms clr $103b turn off high voltage & set to read mode " " 4.3.6 optional eeprom security mode there is an optional security mode feature that can be used to protect the eeprom and ram contents from unauthorized access. most mcu products are of little or no use without the software programs that control them. by protecting the secrecy of the program or a key part of the program, a product can be protected against unauthorized duplication. the MC68HC11a8 solves the dilemma of protecting against unauthorized access while permitting testing and recovery of protected parts for reuse. the protection mechanism operates on the principle of restricting protected devices to the single-chip modes of operation. since single-chip modes do not allow visibility of the internal address and data buses, the contents of memory locations cannot be mon- itored externally. since the users program has unlimited access to the internal ee- prom and ram, it is still possible for the application program to read information out of these memories, write new information into them, or even report the contents of these memories via mcu i/o ports. the user can develop a program to enter secret information into the mcu or to read secret information out of the mcu by some secret access procedure. all or part of this secret access procedure should be programmed in the eeprom so that a software pirate could not decode the secret procedure by disassembling the rom program, which can be read after turning off the security mode. although the security mode can be turned off easily by anyone at any time, this can only be done after the information in eeprom and internal ram have been com- pletely erased. two conditions are required to engage the security option. first, the option must be enabled by a mask option. this option is normally requested at the time the customer submits the mask program for the internal 8-kbyte rom. since this option is enabled or disabled during physical manufacturing of the silicon die, the choice must be made prior to manufacturing. although this first level of enable makes the mcu capable of being secured, it does not activate the security mode. the second requirement to en-
m68hc11 on-chip memory motorola reference manual 4-15 gage the security option is that the nosec bit in the config register be programmed to zero. programming nosec to zero does not engage the security mode unless the mcu was manufactured with the capability to recognize the security option. the rea- son for a two-level enable is to prevent accidental activation of the security option in applications that never intend to use it. bootloader firmware is used to disengage the security option. bootloader firmware checks the nosec bit in config to determine whether or not the security option is on. if security is on, the entire eeprom is erased, and the entire ram is written with $ff to overwrite anything that was in ram before. the eeprom and ram are then rechecked to make sure the erase operations were successful. if the operations were not successful, they are repeated until successful. once the eeprom and ram have been verified as erased, the config register is erased to disengage the security op- tion, and the downloading operation is started. it is not necessary to actually download a program via the bootstrap mode to disengage security. all that is required is to come out of reset in the bootstrap mode. the security option is disengaged regardless of whether anything is downloaded. the presence of the security option can be detected while the mcu is in reset by forc- ing the mode a (moda) and mode b (modb) pins to one and monitoring the strobe a/address strobe (stra/as) pin. when moda and modb are ones, the normal ex- panded mode is requested. if security is engaged, the stra/as pin will act as a high- impedance input because the security option causes the moda pin to be interpreted as a zero even if it is a one. in single-chip modes, the stra/as pin is configured for the strobe a input function. if the security mode is not engaged, the stra/as pin will be acting as the address strobe output, which can easily be recognized on an oscillo- scope. this checking procedure allows the security mode to be detected without dis- engaging it. if the modb pin were low in this experiment, the bootstrap mode would be requested rather than the normal single-chip mode. in the case of modb low, care is required not to release reset because doing so would cause the security option to be disengaged. when developing a security strategy, the user should remember rom contents are not protected. a software pirate can disengage the security option, read the contents of the internal rom, and disassemble the programs and subroutines in that rom. some measures to protect an application program intentionally make the program more difficult to understand. programs that are difficult to understand are also difficult to develop and maintain. careful documentation of the function and intent of every written program is essential. a key can be stored in eeprom. a user can then be required to supply a matching key value before the program will operate. this approach is somewhat weak because all of the operational programs are intact in the rom; thus, a software pirate could find and bypass the key-checking routine. however, if the key-checking routine is repeated in more than one way and place, this approach can make unauthorized access diffi- cult. another approach would be to program a vital subroutine entirely within the eeprom. this approach is better than the previous key-checking approach because the rom
motorola on-chip memory m68hc11 4-16 reference manual does not contain all of the programs needed to make the product function. the weak- ness of this approach is that a software pirate can still duplicate the product after solv- ing that one routine. the pirate also gains a development cost advantage over the original manufacturer, because only part of the application program has to be devel- oped. many application programs are modularly organized as a major loop consisting of calls to submodules. the application relies on both the routines that are called and the order in which they are called. a degree of security can be achieved by putting the major loop (which calls all the subprograms) in the eeprom. in this case, a software pirate can decode the submodules, but the order of execution is not known. to make the pro- gram more difficult to decipher, extra incorrect programs could be included in rom. the software pirate could not distinguish real routines from fake routines. there is a useful side-effect of this approach. since the major loop is resident in the eeprom, it can be changed to call a replacement or patch routine if one of the subprograms is defective. rather than throwing away the entire mcu, the eeprom can be repro- grammed to correct or replace the defective subprogram. another approach to software secrecy involves accessing variables indirectly through a pointer stored in the eeprom. the program in rom could execute a sequence such as loading x with the pointer value from eeprom (ldx addr; ldaa 0,x). since the software pirate does not know what x points to, there is no way of knowing what is being loaded into accumulator a. by mixing direct accesses and indirect accesses to the same variables, the software pirate is unable to recognize that two accesses are to the same variable. 4.4 eeprom application information since eeprom is a relatively new technology, very little published application infor- mation exists. this subsection presents practices that could cause application prob- lems and discusses several practical uses for eeprom on an mcu. next, there is a discussion of the use of eeprom in programs that adjust themselves to accommo- date variable conditions. many applications can benefit from this type of programming, which is presently becoming practical because of the inclusion of eeprom on an mcu. the subsection concludes with a detailed look at some proposed methods to extend the useful write-erase lifetime of the eeprom. 4.4.1 conditions and practices to avoid when programming a new value over an old value in eeprom without first erasing the eeprom location, it is very important to avoid certain data patterns. the most common method for programming a new non-ff value to an eeprom location con- taining a non-ff value is to erase the location before programming the new value. this procedure works for any combination of old and new data values. in less common sit- uations in which an eeprom location endures many write-erase cycles, it may be de- sirable to program a new value over an old value without erasing the location first. this procedure is only possible when the new value has no ones where the eeprom lo- cation already has a zero. a method called write-more-zeros can be used to program additional bits in an eeprom location without erasing the location first, which elimi-
m68hc11 on-chip memory motorola reference manual 4-17 nates a write-erase cycle. another method called selective-write has been proposed but has not been tested and characterized enough to be sure it will work in all cases. in this method, the data pattern used in the programming operation would have ones in all positions except the bits that are zeros in the new value but were ones in the pre- vious value. the idea in this method is to avoid reprogramming bits already pro- grammed. the benefits are theoretical and have not been proven. although both of these methods (write-more-zeros and selective-write) appear to work correctly in lab- oratory experimentation, the combination of the two methods is known to fail. an ex- ample of a failing combination would be to attempt to program $fc to a location that previously contained the value $0d in an attempt to change the location to the value $0c. in this case, bit 1 follows the write-more-zeros method; whereas, bits [4:7] follow the selective-write method. a detailed explanation of this case is given in 4.4.7 soft- ware methods to extend life expectancy . system software should be partitioned so that data and programs in eeprom will never be used while an eeprom programming or erase operation is in progress. when the eelat control bit is set to one at the beginning of a program or erase oper- ation, the eeprom is electronically removed from the mcu memory map; thus, it is not accessible during the programming or erase operation. since it is possible to per- form other tasks while the 10-ms eeprom operation is in progress, it is fairly common to start the operation and return to the main program until the 10 ms is completed. if a routine in the main program or an interrupt tries to access a value in eeprom while a programming operation is in progress, that operation will fail since the eeprom is temporarily inaccessible. in an interrupt-driven system, it may be possible for an asynchronous interrupt to occur in the middle of an eeprom programming or erase operation. such an interrupt can cause the programming or erase operation to extend beyond the normal 10-ms period. a small extension of the programming or erase time will not damage the eeprom or compromise the intended operation. repeated extension or long extensions may in- volve a slight acceleration of write-erase wear-out because wear-out is related to the length of time high voltages are present in the eeprom array. the most significant effects of wear-out occur near the beginning of a program or erase operation because the charge tunneling activity follows an exponential decay curve, which implies that ex- tensions of programming time should have very little effect on the eeprom cell. an- other risk, which is difficult to quantify, is the possibility of high-voltage breakdown of row and column devices due to the presence of programming voltage. if programming and erase times are extended, these devices are exposed to high voltages for a longer time; thus, there is increased risk that a breakdown might occur. in some systems, an eeprom programming or erase operation could be in progress when a power failure or reset occurs, which presents the possibility that an eeprom location might be corrupt or unreliable due to an incomplete programming operation. a way to avoid this problem is to design the system so power failures generate a non- maskable interrupt prior to complete loss of power. this interrupt would allow ee- prom operations to be completed prior to system shutdown. other systems may have battery backup of ram so programming status could be maintained in this mem- ory. upon reset, this status (in ram) could be checked, and any operation that was in
motorola on-chip memory m68hc11 4-18 reference manual progress could be redone to assure reliability. avoid unnecessary erasures of the config register eeprom location. in a normal system, the config register is established during the design of an end product and does not change. in rare cases, the config register may be repro-grammed after a gross system failure accidentally corrupts the intended value. one suggested tech- nique for tolerating such errors involves starting the mcu in special test or special bootstrap mode after any reset. the config register can then be evaluated and changed if necessary. in this scheme, it is not appropriate to routinely erase and re- program the config register. changes should only be made when an error is detect- ed, which minimizes the possibility of wearing out the config eeprom location. 4.4.2 using eeprom to select product options in many applications, it is possible to provide for several product variations with a sin- gle mcu rom pattern. this variation allows a user to pay for a single rom mask charge and amortize the cost over a higher volume of end products. this variation also reduces the customers inventory requirements by reducing the number of unique cus- tomized mcus that have to be stocked. before the availability of on-chip eeprom, it was possible to include multiple program variations in a single rom pattern. the rom program would determine the specific program variation to execute by reading some unique value on an i/o port or by looking for unique devices in the memory map of the finished system. an ideal place to store such optional identifiers is in the on-chip ee- prom. the on-chip eeprom has some advantages over the previous methods. the eeprom method requires no i/o pins for option selection. the eeprom method can accommodate upgrades in the options after the end product is manufactured, and no hardware changes are necessary. a common software technique is to program the various tasks for an application as a series of subroutines, which are called in the de- sired order by a main program loop. the main program loop is usually quite small, con- sisting of little more than a series of jump to subroutine (jsr) instructions. if this main loop is programmed into the on-chip eeprom, it is relatively easy to modify the num- ber and order of rom routines to be executed. 4.4.3 using eeprom for setpoint and calibration information another ideal use for eeprom is for storage of setpoints or calibration information that will not change often. in some older systems, this information had to be entered each time a system was activated. by storing this information in eeprom, the product configuration and setup requirements can be simplified for the end user, and this data can be maintained indefinitely without power. an example of setpoint data would be the temperature setting of a home thermostat or the setback schedule for a more sophisticated thermostat. the two alternatives to storing this information in eeprom are to require that the information be re-entered after a power interruption or to provide relatively expensive batteries and power se- quencing logic. the home thermostat example can also benefit from a calibration table in eeprom. there are many types of temperature sensors with various degrees of accuracy and linearity; however, the most accurate and most linear devices also tend to be the most expensive. since the application dictates a minimum degree of accura-
m68hc11 on-chip memory motorola reference manual 4-19 cy, the designer must decide how to arrive at this accuracy. one approach is to use a very inexpensive sensor and calibrate it at the factory. the combination of on-chip ee- prom and an on-chip analog-to-digital (a/d) converter is ideally suited to this task without requiring any expensive external circuitry. the thermostat could be completely assembled, and calibration information could be determined and stored in the ee- prom during final test of the assembled unit. the software required for this calibration could be part of the on-chip rom program, or it could be loaded from a test fixture via the special bootstrap mode. the bootstrap mode approach offers the advantage that the calibration routines need not occupy any space in the limited internal rom. there are two main approaches to calibration of inexpensive sensors. the choice of the best approach depends primarily on the characteristics of the sensor but also de- pends upon the degree of system accuracy required in the end application. if a sensor is basically linear but has wide variation in absolute offset, a gain-offset approach may be a good choice. this technique requires calibration at two standard levels from which a gain (slope) and offset are determined. the gain and offset values are then stored in eeprom. an actual level is calculated by applying these values algebraical- ly to an a/d input level. although this technique requires some calculations during cal- ibration and during use, it uses very little eeprom space. if a sensor is non-linear, a table-lookup approach may be required. an actual level is determined by using the a/ d reading as an index into the calibration lookup table. during use, this method is very simple and fast, but the lookup table requires more eeprom, and the calibration pro- cess requires more calibration points than the gain-offset method. 4.4.4 using eeprom during product development during product development, the eeprom can be used for storage of data and limit- ed-sized programs. if errors are discovered, they can be corrected even more easily than a program in an eprom. in cases in which there is external memory, such as an eprom in a system under development, it would be a good idea to store the main pro- gram loop in the on-chip eeprom. this approach allows routines in the external eprom to be checked one at a time without reprogramming the external eprom. if errors are discovered, a substitute corrected routine could be programmed into the eeprom to check the corrections before erasing and reprogramming the external eprom. 4.4.5 logging data data logging can involve several types of data. one traditional data type could be tem- peratures measured at specific times of day over a period of weeks or months. other data types could include historical data, such as the number of times a device has been exposed to illegal operating conditions or the total accumulated time a device has been used. this type information can be useful for monitoring product reliability. when such a device is returned to the factory for repair, the historical data can be read out of the eeprom. even if batteries and other power sources failed, this information could be valid. in this context, logging means to make a semi-permanent record of data not requiring power or other normal operating conditions to remain valid. in many cases, there is
motorola on-chip memory m68hc11 4-20 reference manual also an implication that the data is not accessible to the end user for modification (i.e., the end user cannot erase the data by simply removing a battery or unplugging the unit). the on-chip eeprom of the MC68HC11a8 provides a convenient electronic medium for nonvolatile storage of logged data. 4.4.6 self-adjusting systems using eeprom one of the most interesting uses for eeprom in an mcu system is to implement self- adjusting or self-adapting systems. a fairly simple form of self-adaptation would be a system that can calibrate or recalibrate a sensor as it ages. a more sophisticated form of self-adaptation would be a system that can modify its behavior to perform a desired task more efficiently as operating conditions change. the adaptation would be semi- permanent so the modified behavior would be in effect the next time the system was activated (as if the system had originally been programmed that way). any process-control algorithm that includes a feedback mechanism for monitoring re- sults could potentially be programmed to improve itself through self-adaptation. tradi- tionally, process-control programs followed a fixed procedure, which was the result of experimentation and development by engineers. the mcu is an excellent tool for such work because it can quickly repeat complex sets of instructions, including precise tim- ing, with flawless accuracy. unfortunately, this type system often requires tight toler- ances on other system components such as sensors and valves. cheaper (less precise) components could be used if the system provides for calibration, but calibra- tion is often time-consuming and expensive. as technology advanced, some systems were designed to automate the calibration process, thus making it practical to use less precise system components. for these automated systems, the calibration step was still performed outside the context of actual system use. with the m68hc11, it is prac- tical to consider systems that systematically make small adjustments while monitoring end results. depending upon the application, the mcu could either suggest changes to a human operator or directly modify process-control parameters to maintain opti- mum end results. the nonvolatile eeprom is a critical element in such adaptive al- gorithms because it can save what has been learned over a period of time, even if power is lost. consider using an adaptive algorithm in a system consisting of many tasks. high-pri- ority tasks are executed quickly; whereas, low-priority tasks are delayed. one problem is to decide which tasks are most important, which can be accomplished by noting how many times a task was actually needed over some period of time. a second problem is to find some nonvolatile way to maintain the list of high- and low-priority tasks. the main loop could be programmed into eeprom, or the main program could call tasks indirectly through a list of task addresses in the eeprom. a background program could monitor the activity and demands of various tasks and rearrange the priorities to match real application demands. as a task requests more frequent service, it could be elevated in priority, and as a high-priority task reduces its frequency of requests, it could be lowered in priority. in this manner, the tasks requiring the most frequent ser- vice would become the set of tasks that are serviced on every main loop pass. al- though both the fixed priority and the dynamically adaptive priority schemes would accomplish the same amount of work, the adaptive scheme is more responsive. be-
m68hc11 on-chip memory motorola reference manual 4-21 cause the learned priorities would remain in effect through power-off periods, the sys- tem would begin with these learned priorities. as system demands change, priorities would change to match system requirements. 4.4.7 software methods to extend life expectancy eeprom memory is subject to a long-term wear-out mechanism. though the detailed mechanics of the failure mechanism are still the subject of much research, the current understanding is that charge is trapped in the thin oxide layers isolating the floating gate of the eeprom storage transistor. the charge is trapped during tunneling, which only occurs while programming or erasing an eeprom bit. the life expectancy of an eeprom bit is expressed as a number of write-erase cycles (such as 10,000 write- erase cycles). changing a bit from one to zero (write) followed by a change from zero back to one (erase) is considered one write-erase cycle. as a bit accumulates trapped charge and approaches wear-out, the time required to program or erase the location gets longer until the allotted time is no longer enough to program or erase the location, which implies that some extension of life expectancy might be achieved by using long- er programming and erase times. however, the same wear-out mechanism that caus- es longer programming time also causes reduced retention capability. limited data has been collected to support the use of as much as 20 ms for program and erase times rather than the 10 ms suggested in the data sheets. a new MC68HC11a8 oper- ating at 5 v and 2 mhz can typically program an eeprom location in about 2 ms. many factors affect the useful life expectancy of an eeprom location. programming or erasing an eeprom location at high ambient temperature accelerates wear-out. the motorola reliability figures are based on all program and erase operations occur- ring at worst-case ambient temperature, but no realistic application would experience such harsh conditions. temperature has a dramatic effect on write-erase endurance. an eeprom having a life expectancy of 5,000 write-erase cycles at 125 c typically has a life expectancy of 100,000 write-erase cycles at 55 c. motorola publishes a quarterly reliability report which includes the latest life-expectancy data for this rapidly changing technology. the quality of the thin oxides (processing) is maintained at a very high level, but there is still some lot-to-lot variation affecting write-erase endur- ance. the belief is that charge is more easily trapped at sites where the oxide lattice structure is imperfect. the method recommended in motorola data sheets for changing an eeprom byte from one data value (other than $ff) to another is to erase the location before pro- gramming the new value. in this manual, this method will be called erase-before- write. when the new data value contains no ones where there is currently a zero in the eeprom location (no bits need to be erased), there are two additional methods of arriving at the desired value without first erasing the eeprom location. the first of these methods is called program-more-zeros. to program more zeros, the new value would be programmed into the eeprom location. bits previously not programmed will be programmed to zero, and bits already zero remain programmed. the second meth- od, which does not involve erasure of the location before reprogramming, is called se- lective-write. in the selective-write method, a value is calculated that contains zeros in bits needing to change from one to zero and contains ones in all other bits. this cal-
motorola on-chip memory m68hc11 4-22 reference manual culated value is programmed to the eeprom location. the bits corresponding to ze- ros in the calculated pattern become programmed to zeros. the bits already programmed are not reprogrammed but remain zeros. the bits that were not zeros in the old or new data values are not programmed and remain ones. the theoretical ob- jective of the selective-write method is to avoid programming some bits longer than others. the erase-before-write method is used in production testing and for ongoing reliability monitoring. every part that motorola ships is exposed to a significant number of write- erase cycles at high temperature to eliminate parts having infant mortality problems and to identify any lots having processing problems. in addition, sample batches of parts are endurance tested to monitor processing quality. data sheet and reliability fig- ures are based on the erase-before-write method. a problem in production testing was traced to an unsuccessful attempt to program an eeprom location, which unintentionally employed a composite of the program-more- zeros and the selective-write methods. an attempt was made to program an eeprom location with $fc when the location previously contained the value $0d. from what has been said about eeprom programming and the program-more-zeros and selec- tive-write methods, one would expect that the location would change to $0c. in prac- tice, the operation fails if the location was previously $0d but passes if the location was previously $ff. the following table shows the situation more clearly: the expected value shows the value one should expect to get as a result of an attempt to program the value written to an eeprom location already containing the original value. the tester-read value shows what the tester read from the location after the at- tempted programming operation. case b looks odd because the upper four bits are zeros where ones are expected because the location involved was the config reg- ister. reads of the config register of an MC68HC11a8 return zeros in the upper four bits, regardless of what is in the upper four bits of the physical eeprom location. parts that failed (case a) were initially thought to have a defective bit 0 in the config register eeprom location; however, the real problem was finally discovered to be the unintentional combination of the program-more-zeros and selective-write methods. bit 1 is a zero in the original value and the value written (like the program-more-zeros method). the upper four bits are zeros in the original value and ones in the value writ- ten (like the selective-write method). case b, which always works, is equivalent to the erase-before-write method. value case a - fail case b - pass original value 0000 1101 1111 1111 value written 1111 1100 1111 1100 expected result 0000 1100 1111 1100 tester read 0000 1101 0000 1100
m68hc11 on-chip memory motorola reference manual 4-23 note because the user has no way of knowing what is in the upper four bits of the config register eeprom location, the calculated value for the selective-write method cannot be determined. thus, the selective-write method cannot be used for the config location. since the config location is only changed a few times in the lifetime of a product, there is no motivation to use any method other than erase-before-write to change the config location. an examination of the electrical conditions during each of the programming methods explains why the combination of write-more-zeros method and selective-write method fails as it did in case a. this analysis also presents possible advantages and disad- vantages of these programming methods. the basic operation of the floating-gate ee- prom is discussed in 4.3.2 basic operation of the eeprom . figure 4-8 demonstrates the erase-before-write method. one disadvantage of this method is that it requires a time-consuming erase step prior to the programming step. one advantage of this method is that it can be used to change any data pattern to any other data pat- tern. another advantage is that this method is the same as that used for rating the write-erase life expectancy; thus, much characterization data exists to validate this method. the goal of the other two methods is to achieve a longer life expectancy without com- promising data retention or programming integrity. the program-more-zeros method appears to have no risks, and some experimental evidence shows that data retention and program integrity are not compromised. the selective-write method appears to have some theoretical problems, but experimental data has not confirmed any practi- cal problem. due to the theoretical risks of the selective-write method, that method should probably not be used without a complete understanding of the risks. figure 4-9 shows the program-more-zeros method being used to change an ee- prom location from $f0 to $c0. in this example, the low-order four bits were previ- ously programmed, and the current programming operation will change bits 4 and 5 to zeros. it has been suggested that it might be undesirable to program some bits longer than other bits. since charge transfer during programming occurs at an exponentially de- caying rate, it seems unlikely that the additional programming time would result in any significant difference in floating-gate charge. only considerable characterization data can prove or disprove these theories, but preliminary data supports the suggestion that the extra programming time on some bits has no detrimental effects.
motorola on-chip memory m68hc11 4-24 reference manual figure 4-8 erase-before-write programming method figure 4-9 program-more-zeros programming method figure 4-10 shows the selective-write method being used to change an eeprom lo- array ground 7 v pp not driven 654 3210 v tn v ss v pp erase first array ground 7 v pp 654 3210 v ss then program $55 (not driven) 0101 0101 v pp v dd v pp v dd v pp v dd v pp v dd array ground 7 v pp 654 3210 v ss (not driven) 10 0 0 v dd v pp v pp v pp 1 v dd 0 v pp 00 v pp v pp
m68hc11 on-chip memory motorola reference manual 4-25 cation from $f0 to $c0. the calculated data pattern, $cf, was written to the location during this programming operation (note the data pattern and voltage levels across the top of the diagram). the floating gates are highlighted for the bits that should be pro- grammed to zero after the operation. the floating gates of the programmed bits are positively charged so these floating-gate transistors conduct, which introduces an in- teresting question. for bits [3:0], there is a conductive path from v dd to the array ground node. after programming, bits 4 and 5 have a conductive path from v pp to the array ground node. since there is effectively a conductive path from v dd to v pp , how does the selective-write method work? experimental results for this method are good; however, additional study is required. figure 4-10 selective-write programming method the production testing failure provides some additional information about the selec- tive-write method but does not answer all the questions. figure 4-11 shows the volt- ages driving the eeprom bits during the production test failure. the location was previously programmed to $0d, as indicated by the highlighted floating gates. the bit pattern and voltages across the top of figure 4-11 reflect the $fc value that was writ- ten to the location during this programming operation. this programming operation was expected to cause bit 0 to be programmed, but the operation failed (indicated by the bit 0 floating gate not highlighted). this operation fails because there is already a conductive path from v dd to v pp at the start of the programming operation. since the weak v pp supply is shunted to v dd , no programming can occur. the failure of the composite programming case verifies that the conductive paths exist from v dd to the array ground and from v pp to the array ground. the failure also shows that these conductive paths are capable of shunting v pp to a low enough level to pre- vent programming. v pp comes from a charge pump having very little drive-current capability. it is not very surprising that v pp could be effectively shorted to v dd without producing any notice- able load to v dd . in the selective-write method (see figure 4-10 ), the path from v dd to the array ground is conductive from the beginning of the operation. the path from v pp to the array ground (through the bits being programmed) does not become con- ductive until these floating gates are charged to a high enough positive level for the array ground 7 v pp 654 3210 v ss (not driven) 10 1 1 v dd v pp v dd v dd 11 v dd v dd 0 v pp 1 v dd
motorola on-chip memory m68hc11 4-26 reference manual floating-gate transistor to become conductive. it may be that the shunting path does not develop until the bits have already finished programming. if two or more new bits are being programmed and one were to become programmed (conductive) before the other(s), v pp might become shunted before the other bit(s) could finish being pro- grammed. one possible reason this unequal programming problem does not arise is because the bits in a byte are so physically close to each other that they should have nearly identical properties. figure 4-11 composite programming method the selective-write method may result in soft programming. the shunt path may de- velop so late in the programming process that the bits are programmed well enough to be read back as ones but not well enough to provide reliable data retention. on the other hand, soft programming might be beneficial by limiting the stress on the thin ox- ides. the selective-write strategy should be viewed with skepticism until additional study can prove it has merit. in most cases, eeprom locations are only exposed to a few write-erase cycles in the lifetime of a product. in some applications, a few variables need to endure several hun- dred thousand write-erase cycles (e.g., the odometer reading in an automobile). since only a few variables require these extended write-erase cycle lifetimes, it is practical to consider solutions involving the use of multiple eeprom locations for the storage of each such variable. using an eeprom location as an ordinary binary counter is perhaps the worst case for eeprom wear-out because the least significant bit toggles at every count; thus, the eeprom location must be erased and reprogrammed at each count and is exposed to one write-erase cycle for every two counts. a count value could be encoded so that an eeprom location could be programmed eight times by the program-more-zeros method before it has to be erased. in such a scheme, the eeprom location would only experience one write-erase cycle every eight counts. this scheme of bit-position coding would only be needed for the low-or- der bits of a counter since the high-order bits change much less frequently. to extend the write-erase lifetime of a variable even further, using multiple eeprom locations would allow switching to a different location when the current location ap- proached wear-out. the problem is to decide when a location is approaching wear-out. array ground 7 v pp 654 3210 v ss (not driven) 00 1 10 1 v dd v dd v pp v dd v pp v dd 00 v dd v dd
m68hc11 on-chip memory motorola reference manual 4-27 counting the number of times the location has been changed has two problems. first, there is no good way of storing the usage count in eeprom without wearing out the usage count location in the same way as the location being monitored. second, if 10,000 is used as the nominal life-expectancy number, the user may actually wear out the location sooner than expected and fail, or he may not actually be using the location to its potential. the life expectancy is approximately 100,000 write-erase cycles at 55 c even though it is only 5,000 at 125 c.
motorola on-chip memory m68hc11 4-28 reference manual
m68hc11 resets and interrupts motorola reference manual 5-1 section 5 resets and interrupts reset and interrupt operations are often discussed together because they share the common concept of vector fetching to force a new starting point for further central pro- cessing unit (cpu) operations. the reset structure in the MC68HC11a8, which is quite different from other mcus, is presented in this section. this reset system can generate a reset output if reset-causing conditions are detected by internal systems. the on- chip electrically erasable programmable read-only memory (eeprom) also places extra demands on external circuitry connected to the reset pin. the MC68HC11a8 includes 18 separate interrupt sources. on-chip peripheral sys- tems generate maskable interrupts, which are recognized only if the global interrupt mask bit (i) in the condition code register (ccr) is clear. three interrupt sources con- sidered non-maskable will be discussed in detail in this section. maskable interrupts are prioritized according to a default arrangement; however, any one source may be elevated to the highest maskable priority position by a software- accessible control register. this highest priority interrupt (hprio) register may be writ- ten at any time provided the i bit in the ccr is set. when interrupt conditions occur in an on-chip peripheral system, an interrupt status flag is set to indicate the condition. when the users program has properly responded to this interrupt request, the status flag must be cleared. the method of clearing varies from one system to another, depending on the requirements of the system. the vari- ous flag clearing methods and considerations are discussed in 5.7 interrupts from in- ternal peripheral subsystems . 5.1 initial conditions established during reset reset is used to force the microcontroller unit (mcu) to assume a set of initial condi- tions and to begin executing instructions from a predetermined starting address. for most practical applications, the initial conditions take effect almost immediately after applying an active-low level to the reset pin. some reset conditions cannot take ef- fect until/unless a clock is applied to the external clock input (extal) pin. one exam- ple is port b, which acts as an address output port in the expanded modes and as a general-purpose output port in the single-chip modes. during reset in expanded mode, these pins would be $ff because this is the high-order half of $fffe. during reset in single-chip mode, these pins would be $00. since the mode pins are pipelined into the mcu, a clock is needed for the mcu to recognize the mode selected. if no clock is present, the port b pins could be in the wrong state due to the inability of the mcu to recognize the correct mode of operation. if no clock is present, the mcu cannot advance out of the reset condition since internal reset is a clocked sequence; thus, the mcu cannot advance past the first step of this sequence. even with no clock present, a reset signal will cause some changes. most important, an unclocked re-
motorola resets and interrupts m68hc11 5-2 reference manual set signal resets the clock divider circuitry so the on-chip oscillator will start. if an ap- plication includes external clock circuitry driving the extal pin, the reset signal should force this external clock to resume oscillation. 5.1.1 system initial conditions once the reset condition is recognized, internal registers and control bits are forced to an initial state. these initial states, in turn, control on-chip peripheral systems to force them to known start-up states. most of the initial conditions are independent of the op- erating mode. the following paragraphs summarize the initial conditions of the mcu as it leaves reset. 5.1.1.1 cpu after reset, the cpu fetches the restart vector from locations $fffe,ffff ($bffe,bfff if in special test or bootstrap mode) during the first three cycles and be- gins executing instructions. the stack pointer and other cpu registers are indetermi- nate immediately after reset; however, the x and i interrupt mask bits in the ccr are set to mask any interrupt requests. also, the s bit in the ccr is set to disable the stop mode. 5.1.1.2 memory map after reset, the ram and i/o mapping (init) register is initialized to $01, putting the 256 bytes of random-access memory (ram) at locations $0000C$00ff and the con- trol registers at locations $1000C$103f. the 8-kbyte read-only memory (rom) and/ or the 512-byte eeprom may or may not be present in the memory map because the two bits that enable them in the configuration control (config) register are eeprom cells not affected by reset or power-down. 5.1.1.3 parallel i/o when a reset occurs in expanded-multiplexed operating mode, the 18 pins used for parallel i/o are dedicated to the expansion bus. if a reset occurs in the single-chip op- erating mode, the strobe a flag (staf), strobe a interrupt (stai), and handshake (hnds) control bits in the parallel input/output control (pioc) register are cleared so that no interrupt is pending or enabled, and the simple strobed mode (rather than full- handshake mode) of parallel i/o is selected. the port c wired-or mode (cwom) bit in pioc is cleared. port c is initialized as an input port (data direction register for port c, ddrc $00); port b is a general-purpose output port with all bits cleared. stra is the edge-sensitive strobe a input, and the active edge is initially configured to detect rising edges (edge select for strobe a (ega) bit in pioc is set). port c, port d (bits [5:0]), port a (bits 0, 1, 2, and 7), and port e are configured as general-purpose high- impedance inputs. port b and bits [6:3] of port a have their directions fixed as outputs, and their reset state is logic zero. 5.1.1.4 timer during reset, the timer system is initialized to a count of $0000. the prescaler bits are cleared, and all output-compare registers are initialized to $ffff. all input-capture
m68hc11 resets and interrupts motorola reference manual 5-3 registers are indeterminate after reset. the output-compare 1 (oc1m) mask register is cleared so that successful oc1 compares do not affect any i/o pins. the other four output compares are configured to not affect any i/o pins on successful compares. all three input-capture edge-detector circuits are configured for capture-disabled opera- tion. the timer overflow interrupt flag and all eight timer function interrupt flags are cleared. all nine timer interrupts are disabled since their mask bits are cleared. 5.1.1.5 real-time interrupt the real-time interrupt flag is cleared, and automatic hardware interrupts are masked. the rate control bits are cleared after reset and may be initialized by software before the real-time interrupt system is used. 5.1.1.6 pulse accumulator the pulse accumulator system is disabled at reset so that the pulse accumulator input (pai) pin defaults to being a general-purpose input pin. 5.1.1.7 cop watchdog the computer operating properly (cop) watchdog system is enabled if the nocop control bit in the config register (eeprom cell) is clear and disabled if nocop is set. the cop rate is set for the shortest duration time-out. 5.1.1.8 serial communications interface (sci) the reset condition of the sci system is independent of the operating mode. at reset, the sci baud rate is indeterminate and must be established by a software write to the baud register. all transmit and receive interrupts are masked, and both the transmit- ter and receiver are disabled so the port pins default to being general-purpose i/o lines. the sci frame format is initialized to an 8-bit character size. the send break and receiver wake-up functions are disabled. the transmit data register empty (tdre) and transmit complete (tc) status bits in the sci status register are both set, indicating that there is no transmit data in either the transmit data register or the transmit serial shift register. the receive data register full (rdrf), idle, overrun (or), and framing error (fe) receive-related status bits are all cleared. upon reset in special bootstrap mode, execution begins in the 192-byte bootstrap rom, which changes some of the initial conditions by the time the bootloading process is finished. this firmware sets port d to wired-or mode, establishes a baud rate, and enables the sci receiver and trans- mitter. 5.1.1.9 serial peripheral interface (spi) the spi system is disabled by reset. the port pins associated with this function default to being general-purpose i/o lines. 5.1.1.10 analog-to-digital (a/d) converter the a/d converter system configuration is indeterminate after reset. the conversion complete flag is cleared by reset. the a/d power-up (adpu) bit is cleared by reset, disabling the a/d system.
motorola resets and interrupts m68hc11 5-4 reference manual 5.1.1.11 other system controls the eeprom programming controls are all disabled so the memory system is config- ured for normal read operation. the highest priority i bit interrupt defaults to being the external interrupt request ( irq) pin by psel[3:0] equal to 0:1:0:1. the irq pin is con- figured for level-sensitive operation (for wired-or systems). the read bootstrap rom (rboot), special mode (smod), and mode a (mda) bits in the hprio register reflect the status of the mode b (modb) and moda inputs at the rising edge of reset. the enable oscillator start-up delay (dly) control bit is set to specify that an oscillator start- up delay is imposed upon recovery from stop mode. the clock monitor system is dis- abled by clock monitor enable (cme) equals zero. the MC68HC11a8 has three internal sources that can cause reset as well as the ex- ternal application of a low level to the reset pin. no matter which of these sources causes reset, the entire mcu is reset. the reset pin is driven low as a result of any of the reset sources. the only distinction that is made between the causes of reset is the reset vector, which is used to tell the cpu the starting address for execution when reset is released. a few registers are not forced to a start-up condition as a result of reset. since these registers do not affect the starting conditions at mcu pins, it is not important to force them to a start-up state during reset. one such example is the main-timer input-cap- ture registers. since these registers are not useful until after an input capture occurs, it is not important to force them to a start-up state during reset. 5.1.2 config register allows flexible configuration the m68hc11 includes a nonvolatile config register, which controls a number of options typically controlled by mask options or by additional mode selection choices in other mcus. by using a nonvolatile eeprom-based register, it is possible to achieve the same effects as if the options were mask programmed and, at the same time, allow users to change these features after the mcu is manufactured. the most important aspect of this method of selecting options is that the selections automatically take ef- fect on any power-up or reset without any software intervention. two classes of fea- tures can be controlled in this manner. first, there are configuration choices that must inherently be made before the reset vector is even fetched. for example, the rom en- able must be decided so that the reset vector can be fetched out of the correct memory as the mcu comes out of reset. the cop watchdog timer enable is an example of the second class of features that can be controlled by an eeprom bit. the cop watch- dog timer is intended to detect software failures; thus, it is important to enable or dis- able this feature without any software intervention. if software could disable or was required to enable the cop watchdog, the cop watchdog timer could not detect a fail- ure of that software. the config register controls the presence or absence of rom and/or eeprom, en- ables/disables the cop watchdog timer, and engages/disengages the security option. the config register and mechanism are described in greater detail in 3.2.1 opera- tion of config mechanism . the features enabled by the config register can be thought of as mask-programmed options that do not require software service.
m68hc11 resets and interrupts motorola reference manual 5-5 5.1.3 mode of operation established during reset, the basic mode of operation is established, which determines whether the mcu will operate as a self-contained single-chip system or as an expanded sys- tem that includes external memory resources. there are also special variations of these two basic modes of operation. the bootstrap mode is the special variation of the normal single-chip mode, and the special test mode is the special variation of the nor- mal expanded mode. the levels on the two mode select pins during reset determine which of these four modes of operation will be selected. the hardware mode select mechanism begins with the logic levels on the moda and modb pins while the mcu is in the reset state. the logic levels on the moda and modb pins are fed into the mcu via a clocked pipeline path. the captured levels will be those that were present part of a clock cycle before the reset pin rose. this fact assures a zero hold-time requirement on the mode select pins relative to the rising edge at the reset pin. the captured levels determine the logic state of the smod and mda control bits in the hprio register. these two control bits actually control the logic circuits involved in hardware mode selection. table 5-1 summarizes the opera- tion of the mode pins and mode control bits. 5.1.4 program counter loaded with reset vector as reset is released, the cpu program counter is loaded with the reset vector that points to the first instruction in the users program. depending on the cause of reset and the mode of operation, the reset vector may be fetched from any of six possible locations. in older motorola mcus, there was only one reset vector at $fffe,ffff. 5.2 causes of reset in the MC68HC11a8, there are on-chip systems that can detect mcu system failures and generate a low level out the reset pin to reinitialize other peripherals in the sys- tem. to distinguish between these causes, separate reset vectors are used. the pri- mary reset vector is used when the cause of reset is the internal power-on reset circuit or application of a low level to the reset pin. in normal expanded and normal single- chip modes, this vector is located at $fffe,ffff. if the oscillator input stops or is run- ning too slow, the clock monitor circuit will generate a reset (provided the clock monitor is enabled). time-out of the internal cop watchdog timer will generate a reset (provid- ed the cop system is enabled). table 5-2 summarizes the reset-vector locations ver- sus the cause of reset and mode of operation. table 5-1 hardware mode select summary inputs mode description control bits in hprio (latched at reset) modb moda rboot smod mda inputs 10 normal single chip 0000 1 1 normal expanded 0000 0 0 special bootstrap 0010 0 1 special test 0111
motorola resets and interrupts m68hc11 5-6 reference manual in special test and bootstrap modes, mcu vectors are located at $bfc0C$bfff rath- er than the normal $ffc0C$ffff area. the primary reason for this change is to be sure the reset vector can be supplied from an external source in special test mode. the normal reset vector is located at $fffe,ffff, which can be internal rom or ex- ternal memory space (depending on whether the internal rom is enabled). the spe- cial test mode reset vector is at $bffe,bfff, which is always an external access independent of other system conditions. this alternate mapping is important to the operation of bootstrap mode because it al- lows reset and other vectors to be located within the 192-byte bootloader rom. as the mcu comes out of reset in special bootstrap mode, the reset vector is fetched out of the bootloader rom, and execution begins at the start of the bootloader program. while in bootstrap mode, interrupts can be vectored to locations in the bootloaded pro- gram in ram rather than vectoring to the routines specified in the internal rom pro- gram. the m68hc11 mcu is capable of distinguishing between an external reset and resets from the internal cop and clock monitor systems. when the cop watchdog timer times out or the clock monitor detects a clock failure, the cop and clock monitor status is temporarily saved. the reset pin is then driven low for about four e-clock cycles and is released. two e-clock cycles later, the reset input is sampled. if reset is high (has risen to logic one within the two cycles since it was released), the source of reset is presumed to be either the cop or clock monitor system. if reset is still low, the source is presumed to be an external reset request, and the temporarily saved sta- tus from the cop and clock monitor systems is erased. although there would rarely be more than one cause for a particular reset sequence, the three reset vectors are prioritized. if an external reset request drives the reset pin low for less than four e- clock cycles, the differentiation logic could assume the source of reset was the internal cop or clock monitor system; however, as long as neither of these causes was indi- cated by the temporarily latched status, the normal reset vector would still be used by default. although this mcu can differentiate between different reset causes, the most common implementation would direct all reset vectors to the same initialization soft- ware, regardless of the cause of reset. there are four possible sources of reset in the MC68HC11a8. an internal circuit de- tects the rising edge on v dd and initiates a power-on reset. an on-chip cop watchdog timer monitors proper software execution; if software does not service this timer within its time-out period, a system reset is generated. another on-chip circuit monitors the mcu clock frequency. if the mcu clock stops or is running too slow, a system reset is generated. finally, a user can initiate an external reset by momentarily driving the re- set pin low. the cop and clock monitor features can be disabled. the power-on re- table 5-2 reset vector vs. cause and mcu mode cause of reset normal mode vector special test or bootstrap vector por or reset pin $fffe,ffff $bffe,bfff clock monitor fail $fffc,fffd $bffc,bffd cop watchdog time-out $fffa,fffb $bffa,bffb
m68hc11 resets and interrupts motorola reference manual 5-7 set and external reset share the normal reset vector; whereas, the cop and clock monitor reset each have their own vector. the four causes of reset are described in greater detail in the following paragraphs. 5.2.1 power-on reset (por) the por is only intended to initialize internal mcu circuits. as v dd is applied to the mcu, the por circuit triggers and initiates a reset sequence. por triggers an internal timing circuit that holds the reset pin low for 4064 cycles of the internal ph2 clock. the mcu does not advance past this reset condition until a clock is present at the ex- tal pin long enough for these 4064-cycle ph2 clocks to be detected. the internal por circuit will not retrigger unless v dd has discharged to 0 v; therefore, the internal por circuit is not suitable as a power-loss detector. in almost all m68hc11 systems, there will be an external circuit to hold the reset pin low whenever v dd is below normal operating level. this external voltage-level detec- tor or other external reset circuits are the normal source of reset in a system; the inter- nal por circuit only serves to initialize internal control circuitry during cold starts. in some unusual applications, it may be desirable to hold reset low long enough for the oscillator to reach stable operating frequency. this stable operating frequency is not a requirement of the mcu because the m68hc11 is a fully static design, which can operate correctly even when the oscillator has not reached stable operating frequency. if the oscillator has not reached stable operating frequency by the time reset is re- leased, software and timed delays will be longer than expected since these delays are based on the oscillator frequency. in most applications, such errors within the first few milliseconds of operation are of no concern, and no external power-on delay is neces- sary. in cases where timing is critical immediately out of reset, an external por cir- cuit must be provided. the required amount of delay depends upon the oscillator startup time, which varies with the frequency and design of the oscillator as well as such things as v dd rise time. in a typical m68hc11 design with an e-clock frequency of 2 mhz, the internal por will only hold reset low for about 2 ms after oscillator start. with an 8-mhz crystal, the m68hc11 oscillator will typically start when v dd reaches about 1 v. for a typical v dd rise time, the internal por times out well before v dd reaches an acceptable level. thus, por alone is rarely able to provide for all re- set needs, and some external reset circuitry will be required. 5.2.2 cop watchdog timer reset the cop watchdog timer system is intended to detect software processing errors. when the cop is being used, software is responsible for keeping a free-running watchdog timer from timing out. if the watchdog timer times out, it is an indication that software is no longer being executed in the intended sequence; thus, a system reset is initiated. the cop system is enabled or disabled, depending on the state of the nocop bit in the config register. this enable is like a mask option in that it is effective immediate- ly out of reset and is not dependent on any software action. unlike a programmed mask option, the cop enable may be changed by the end user. the requirements for
motorola resets and interrupts m68hc11 5-8 reference manual changing the enable bit are designed so the nocop bit is very unlikely to be changed by accident in the end system. the only way to change the enable status of the cop system is to change the contents of the eeprom-based config register. even after the nocop bit is changed, the mcu must be reset before the new status becomes effective. in the special test and bootstrap operating modes, the cop system is initially inhibited by the disable resets (disr) control bit in the test1 register. the disr bit can be written to zero to enable cop resets while the mcu is in special test or boot- strap operating mode. the cop time-out period is set by the cop timer rate control bits (cr1 and cr0) in the configuration options (option) register. after reset, these bits are both zero, which selects the fastest time-out period. the mcu internal e clock is first divided by 2 15 before it enters the cop watchdog system. the cr1 and cr0 bits control a further scaling factor for the watchdog timer (see table 5-3 ). the columns at the right of the table show the resulting watchdog time-out periods for three typical oscillator frequen- cies. in normal operating modes, these bits can only be written once, and that write must be within 64 bus cycles after reset. the cop timer must be reset by a software sequence prior to time-out to avoid a cop reset. the software cop reset is a two-step sequence. the first step is to write $55 to the coprst register to arm the cop timer-clearing mechanism. the second step is to write $aa to the coprst register, which clears the cop timer. any number of in- structions can be performed between these two steps as long as both steps are per- formed in the correct sequence before the timer times out. this reset sequence is sometimes referred to as servicing the cop timer. since the cop timer is based on the mcu clock, the cop watchdog cannot detect er- rors that cause the mcu clock to stop. the clock monitor system (see 5.2.3 clock monitor reset ) can be used as a backup for cop to force a system reset if the mcu clocks stop. placing the cop service instructions in an interrupt service routine is bad practice. in such a case, the interrupt could occur often enough to keep the cop system satisfied even if the main-line program was no longer functioning. the implementation of the cop timer causes a tolerance on the time-out period. the table 5-3 watchdog rates vs. crystal frequency cr1 cr0 e ? 2 15 divided by crystal frequency 2 23 hz 8 mhz 4 mhz nominal time-out 0 0 1 15.625 ms 16.384 ms 32.768 ms 0 1 4 62.5 ms 65.536 ms 131.07 ms 1 0 16 250 ms 262.14 ms 524.29 ms 1 1 64 1 s 1.049 s 2.1 s 2.1 mhz 2 mhz 1 mhz bus frequency (e clock)
m68hc11 resets and interrupts motorola reference manual 5-9 e divided by 2 15 clock into the cop system is free-running and, for practical purposes, is asynchronous to the cop service software. all additional divider stages in the cop timer are reset each time the cop service sequence is performed. there is an uncer- tainty about when the first e divided by 2 15 clock will reach the cop timer stages. this uncertainty causes the specified time-out period to have a tolerance of minus zero to plus one cycle of the e divided by 2 15 clock. this tolerance varies with e-clock frequen- cy but does not change with respect to the cop rate selected by the cr1 and cr0 bits. figure 10-3 and 10.2.3 cop watchdog function contain additional information about this clocking structure. 5.2.3 clock monitor reset the clock monitor circuit is based on an internal resistor-capacitor (rc) time delay. if no mcu clock edges are detected within this rc time delay, the clock monitor can op- tionally generate a system reset. the clock monitor function is enabled/disabled by the cme control bit in the option register. this time-out is based on an rc delay so that the clock monitor can operate without any mcu clocks. processing variations cause the rc time-out to vary somewhat from lot to lot and part to part. an e-clock frequency below 10 khz will definitely be detected as a clock mon- itor error. an e-clock frequency of 200 khz or more will prevent clock monitor errors. any system operating below 200 khz e-clock frequency should not use the clock mon- itor function. when the clock monitor is enabled and the mcu clocks slow down or stop, a system reset is generated. the bidirectional reset pin is driven low to reset the external sys- tem and the mcu. clock monitor has a separate reset vector from cop reset and ex- ternal reset to enable software to determine the cause of reset. while the mcu is in special test or bootstrap mode, resets from the cop and clock monitor systems are initially disabled by a one in the disr bit in the test1 register. while still in the special operating modes, cop and clock monitor resets can be re-enabled by writing the disr control bit to zero. in normal operating modes, the disr bit is forced to zero and cannot be set to one. clock monitor is often used as a backup for the cop watchdog system. since the cop needs a clock to function, it is unable to function if the clocks stop. in such a case, the clock monitor system could detect clock failures not detected by the cop system. another use for the clock monitor is to protect against the unintentional execution of the stop instruction. some applications view the stop instruction as a serious prob- lem because it causes mcu clocks to stop, thus disabling all software execution and on-chip peripheral functions. a stop disable bit (s) in the ccr is the first line of defense against unwanted stop instructions. while the s bit is one, the stop instruction acts as a no-operation (nop) instruction, which does not interfere with mcu clock opera- tion. clock monitor can provide an additional level of protection by generating a sys- tem reset if the mcu clocks are accidentally stopped. it is possible to use the clock monitor in systems that also use the stop instruction. in such a system, the cme control bit would be written to zero to disable the clock
motorola resets and interrupts m68hc11 5-10 reference manual monitor prior to executing an intentional stop instruction. after recovery from stop, the cme bit would be written to one to enable the clock monitor during normal execu- tion. the reset sequence is a clocked operation; whereas, clock monitor resets are gener- ated when the clocks stop. in many cases, the low level on reset will correct the cause of the stopped mcu clocks, and recovery can proceed much as in the cop re- set case. in cases where the mcu clocks do not resume as a result of the clock mon- itor reset, the driven low level at the reset pin will remain indefinitely. 5.2.4 external reset in addition to the internal sources, reset can be forced by applying a low level to the reset pin. the resulting reset sequence is identical to the internal causes. upon rec- ognition of the reset request, internal logic turns on an internal n-channel device, which actively holds the reset pin low for about four cycles. in a normal system, the external source of reset would be redundantly driving the pin low during this time and would continue to hold the pin low longer than this four cycles. two e-clock cycles after the internal n-channel driver releases the pin, the reset pin is sampled. a low level at this time indicates the reset was caused by some external source. when the reset pin is eventually released, the normal reset vector is fetched and processing begins. in all cases of reset, the internal n-channel device holds the reset pin low for at least four e-clock cycles. all resets cause internal registers and on-chip peripherals to be re-initialized. the only difference between causes of reset is the vector locations used. in the abnormal case where the reset pin is not held low long enough to be detected as the cause, the reset is tentatively assumed to have come from the cop or clock monitor systems. priority logic assigns highest priority to the clock monitor and second highest priority to the cop watchdog. if neither of these sources is pending, the normal reset vector is selected by default. in another abnormal case where the reset line is loaded by too much capacitance to rise within two cycles after the internal n-channel turns off, there will be no way for the internal logic to discriminate between an internal or external reset source; thus, all resets are interpreted as external requests. figure 5-1 shows an example of an external reset circuit. the low voltage inhibit (lvi) device [1] holds reset low whenever v dd is below operating level. the lvi device [2] and the rc on its input provide an external por delay. the switch [3] provides for manual reset. voltage detectors [1] and [2] have open-drain outputs, and the pull-up resistor holds the reset pin high unless either voltage detector or the internal mcu reset circuitry drives the reset pin low. the lvi circuit [1] (or some equivalent circuit) is required for virtually all m68hc11 systems. the external por delay and manual re- set switch are optional. for many applications, the voltage detector [1] and the pull-up resistor [4] are the only external components needed for reset.
m68hc11 resets and interrupts motorola reference manual 5-11 figure 5-1 typical external reset circuit 5.3 interrupt process the cpu in a microcontroller sequentially executes instructions. in many applications, it is necessary to execute sets of instructions in response to requests from various pe- ripheral devices. these requests are often asynchronous to the execution of the main program. interrupts provide a way to temporarily suspend normal program execution so the cpu can be freed to service these requests. after an interrupt has been ser- viced, the main program resumes as if there had been no interruption. the instructions executed in response to an interrupt are called the interrupt service routine. these routines are much like subroutines except that they are called through the automatic hardware interrupt mechanism rather than by a subroutine call instruc- tion, and all cpu registers are saved on the stack rather than just saving the program counter. an interrupt (provided it is enabled) causes normal program flow to be sus- pended as soon as the currently executing instruction finishes. the interrupt logic then pushes the contents of all cpu registers onto the stack so the cpu context can be restored after the interrupt is finished. after stacking the cpu registers, the vector for the highest priority pending interrupt source is loaded into the program counter, and execution continues with the first instruction of the interrupt service routine. an inter- rupt is concluded with a return from interrupt (rti) instruction, which causes all cpu registers and the return address to be recovered from the stack so that the interrupted program can resume as if there had been no interruption. interrupts can be enabled or disabled by mask bits (x and i) in the ccr and by local enable mask bits in the on-chip peripheral control registers. a few important interrupt sources that are always enabled are called non-maskable interrupts. the non- maskable interrupt request ( xirq) pin is effectively a non-maskable interrupt source except that it is disabled immediately after reset. very special logic is associated with the interrupt mask bit (x) for xirq in the ccr to overcome classic problems associ- ated with a non-maskable interrupt while allowing all of the benefits of such an inter- rupt. the remaining interrupt sources are maskable by the interrupt mask bit (i) in the 4.7 k w 3 1 2 3 1 2 [4] [3] [2] [1] to reset v dd mc34064 reset gnd in of m68hc11 reset gnd in manual reset switch r1 c mc34164 r2 v dd v dd
motorola resets and interrupts m68hc11 5-12 reference manual ccr. the interrupt mask bits in the ccr provide a means of controlling the nesting of inter- rupts. in rare cases, it may be useful to allow an interrupt routine to be interrupted (nesting of interrupts). nesting of interrupts is discouraged because it greatly compli- cates a system and rarely improves system performance. by default, the interrupt structure inhibits interrupts during the interrupt entry sequence by setting the interrupt mask bit(s) in the ccr. as the ccr is recovered from the stack during the rti instruc- tion, the ccr bits return to the enabled state so additional interrupts can be serviced. if nesting of interrupts is desired, it must be specifically allowed by clearing the inter- rupt mask bit(s) after entering the interrupt service routine. care must be taken to spe- cifically mask (disable) the present interrupt with a local enable mask bit or to clear the interrupt source flag before clearing the mask bit in the ccr; otherwise, the same source would immediately interrupt, and an infinite loop could result. upon reset, both the x and i bit are set to inhibit all maskable interrupts and xirq. after minimum system initialization, software may clear the x bit by a transfer accumu- lator a to ccr (tap) instruction, thus enabling xirq. thereafter, software cannot set the x bit; thus, an xirq is effectively a non-maskable interrupt. since the operation of the i-bit-related interrupt structure has no effect on the x bit, the external xirq pin re- mains effectively non-maskable. in the interrupt priority logic, xirq is a higher priority than any source that is maskable by the i bit. all i-bit-related interrupts operate normal- ly with their own priority relationship. when an i-bit-related interrupt occurs, the i bit is automatically set by hardware after stacking the ccr byte, but the x bit is not affected. when an xirq occurs, both the x and i bits are automatically set by hardware after stacking the ccr. an rti instruction restores the x and i bits to their pre-interrupt re- quest state. 5.3.1 interrupt recognition and stacking registers an interrupt can be recognized at any time provided it is enabled by its local mask (if any) and by the global mask bit in the ccr. once any interrupt source is recognized, the cpu will respond at the completion of the currently executing instruction. instruc- tions cannot be interrupted; rather, the cpu decides whether to fetch another instruc- tion or process an interrupt. in calculating the latency time from the actual interrupt request to the cpu response to that request, the user must consider the possibility that the cpu had just started a long instruction as the interrupt was requested. most in- structions are two to four cycles long, but the multiply (mul) and integer divide (idiv) or fractional divide (fdiv) instructions are 10 and 41 cycles, respectively. when the cpu decides to service an interrupt, the contents of cpu registers are pushed (stored) on the stack in the order pcl, pch, iyl, iyh, ixl, ixh, acca, accb, ccr. after the ccr value is stacked, the i bit in the ccr (and the x bit if xirq is pending) is set to inhibit further interrupts. the interrupt sequence then proceeds to the priority resolution step. 5.3.2 selecting interrupt vectors after the ccr has been stacked, the cpu evaluates all pending interrupt requests to
m68hc11 resets and interrupts motorola reference manual 5-13 determine which source has the highest priority. since the priority resolution step oc- curs several cycles after the original decision to service an interrupt, a higher priority source could become pending after the stacking operation started but before the pri- ority is resolved. in such a case, the interrupt that is serviced can be different from the source that initiated the interrupt sequence. this subtle aspect means that the latency from an interrupt request to when it is serviced can be shorter than expected. interrupts obey a fixed hardware-priority circuit to resolve simultaneous requests; how- ever, one i-bit-related interrupt source may be elevated to the highest i bit priority po- sition in the resolution circuit. the first six interrupt sources are not masked by the i bit in the ccr and have the fixed priority interrupt relationship: reset, clock monitor fail, cop fail, illegal opcode, and xirq. each of these sources is an input to the priority resolution circuit. software interrupt (swi) is actually an instruction and has the high- est priority other than reset because, once the swi opcode is fetched, no other inter- rupt can be honored until the swi vector has been fetched. the highest i-bit-related priority input is assigned under software control (of the hprio register) to be connect- ed to any one of the remaining i-bit-related interrupt sources. to avoid timing races, the hprio register may only be written while the i-bit-related interrupts are inhibited (i bit in ccr = 1). an interrupt that is assigned to this highest priority position is still subject to masking by any associated control bits or by the i bit in the ccr. the inter- rupt vector address is not affected by assigning a source to this highest priority posi- tion. the following figure shows the hprio register. the hprio register may be read at any time but may only be written under special circumstances. the high-order four bits of hprio may only be written while the mcu is operating in one of the special modes (smod = 1). the low-order four bits may only be written while the i bit in the ccr is one. rboot read bootstrap rom can be written only while smod equals one 1 = bootstrap rom enabled and located from $bf40C$bfff 0 = bootstrap rom disabled and not present in memory map the rboot control bit enables or disables the special bootstrap control rom. this 192-byte mask-programmed rom contains the firmware required to load a users pro- gram through the sci into the internal ram and jump to the loaded program. in all modes other than the special bootstrap mode, this rom is disabled and does not oc- cupy any space in the 64-kbyte memory map. although it is zero when the mcu comes out of reset in test mode, the rboot bit may be written to one while in special test mode. smod special mode may be written to zero but not back to one hprio highest priority i-bit interrupt and miscellaneous $103c bit 7 654321 bit 0 rboot smod mda irv psel3 psel2 psel1 psel0 reset: (refer to table 5-1 )
motorola resets and interrupts m68hc11 5-14 reference manual 1 = special mode variation in effect 0 = normal mode variation in effect mda mode a select can be written only while smod equals one 1 = normal expanded or special test mode in effect 0 = normal single-chip or special bootstrap mode in effect irv internal read visibility can be written only while smod equals one; forced to zero if smod equals zero 1 = data driven onto external bus during internal reads 0 = data from internal reads not visible on expansion bus (levels on bus ignored) the irv control bit is used during factory testing and sometimes during emulation to allow internal read accesses to be visible on the external data bus. care is required to avoid data bus contention while irv is active because the bidirectional data bus is driv- en out during reads of internal addresses, even though the r/ w line suggests the data bus is in the high-impedance read mode. in normal modes, this function is disabled; thus, complex decode logic is not required to protect against accidental bus conflicts. psel[3:0] priority select bits 3:0 can be written only while i bit in ccr equals one. these four bits allow any one maskable interrupt source to be elevated to the highest priority position. non- maskable interrupts still take priority over all maskable interrupts. the following table shows the relationship between the psel[3:0] bit values and the interrupt source that is promoted. the priority can only be changed while interrupts are masked (i bit in ccr = 1) to avoid race conditions. figure 5-2 , figure 5-4 , and figure 5-6 illustrate the interrupt process as it relates to table 5-4 highest priority 1 interrupt vs. psel[3:0] psel3 psel2 psel1 psel0 interrupt source promoted 0000 timer overflow 0001 pulse accumulator overflow 0010 pulse, accumulator input edge 0011 spi transfer complete 0100 sci serial system 0101 reserved (default to irq) 0110 irq (external pin or parallel i/o) 0111 real-time interrupt 1000 timer input capture 1 1010 timer input capture 2 1010 timer input capture 3 1011 timer output compare 1 1100 timer output compare 2 1101 timer output compare 3 1110 timer output compare 4 1111 timer output compare 5
m68hc11 resets and interrupts motorola reference manual 5-15 normal processing. figure 5-2 shows how the cpu begins from a reset and how in- terrupt detection relates to normal opcode fetches. figure 5-4 , an expansion of a block in figure 5-2 , shows how interrupt priority is resolved. figure 5-6 , an expansion of the sci interrupt block in figure 5-4 , shows the resolution of interrupt sources within the sci subsystem.
motorola resets and interrupts m68hc11 5-16 reference manual figure 5-2 processing flow out of resets (sheet 1 of 2) 1b bit x in y n xirq y n pin low? ccr = 1? begin instruction sequence 1a stack cpu registers set bits i and x fetch vector $fff4, $fff5 set bits s , i , and x reset mcu hardware power-on reset (por) external reset clock monitor fail (with cme = 1) cop watchdog timeout (with nocop = 0) delay 4064 e cycles load program counter with contents of $fffe, $ffff (vector fetch) load program counter with contents of $fffc, $fffd (vector fetch) load program counter with contents of $fffa, $fffb (vector fetch) highest priority lowest priority
m68hc11 resets and interrupts motorola reference manual 5-17 figure 5-3 processing flow out of resets (sheet 2 of 2) bit i in ccr = 1? 1b y n any i-bit interrupt y n pending? fetch opcode illegal opcode? y n wai y n instruction? swi instruction? y n rti instruction? y n execute this instruction stack cpu registers any n y interrupt pending? set bit i in ccr resolve interrupt priority and fetch vector for highest pending source stack cpu registers set bit i in ccr fetch vector $fff8, $fff9 stack cpu registers set bit i in ccr fetch vector $fff6, $fff7 restore cpu registers from stack 1a stack cpu registers see figure 5C3
motorola resets and interrupts m68hc11 5-18 reference manual figure 5-4 interrupt priority resolution (sheet 1 of 2) 2a begin set x bit in ccr fetch vector $fff4, fff5 x bit in ccr set ? yes no xirq pin low ? yes no highest priority interrupt ? yes no irq ? yes no fetch vector $fff2, fff3 fetch vector $fff0, fff1 rtii = 1 ? yes no real-time interrupt ? yes no fetch vector $ffee, ffef ic1i = 1 ? yes no timer ic1f ? yes no fetch vector $ffec, ffed ic2i = 1 ? yes no timer ic2f ? yes no fetch vector $ffea, ffeb ic3i = 1 ? yes no timer ic3f ? yes no fetch vector $ffe8, ffe9 oc1i = 1 ? yes no timer oc1f ? yes no 2b fetch vector
m68hc11 resets and interrupts motorola reference manual 5-19 figure 5-5 interrupt priority resolution (sheet 2 of 2) toi = 1? y n y n paovi = 1? paii = 1? y n spie = 1? y n y n flag y n y n flag flag y n flags y n paif = 1? spif = 1? or tof = 1? paovf = 1 fetch vector $ffde, $ffdf fetch vector $ffdc, $ffdd fetch vector $ffda, $ffdb fetch vector $ffd6, $ffd7 fetch vector $ffd8, $ffd9 oc2i = 1? y n y n oc3i = 1? oc4i = 1? y n oc5i = 1? y n flag y n y n flag flag y n flag y n oc4f = 1? oc5f = 1? oc2f = 1? oc3f = 1 fetch vector $ffe6, $ffe7 fetch vector $ffe4, $ffe5 fetch vector $ffe2, $ffe3 fetch vector $ffe0, $ffe1 modf = 1? interrupt? see figure 5-4 2a 2b end fetch vector $fff2, $fff3 sci
motorola resets and interrupts m68hc11 5-20 reference manual figure 5-6 interrupt source resolution within sci 5.3.3 return from interrupt when an interrupt has been serviced as needed, the rti instruction terminates inter- rupt processing and returns to the program that was running at the time of the inter- ruption. during servicing of the interrupt, some or all of the cpu registers will have changed. to continue the former program as if it had not been interrupted, the regis- ters must be restored to the values present at the time the former program was inter- rupted. the rti instruction accomplishes this by pulling (loading) the saved register values from the stack memory. the last value to be pulled from the stack is the pro- gram counter, which causes processing to resume where it was interrupted. 5.4 non-maskable interrupts this subsection discusses the illegal opcode fetch interrupt, the swi instruction, and flag y n or = 1? y n y n tdre = 1? tc = 1? y n idle = 1? y n y n y n y n ilie = 1? rie = 1? tie = 1? begin re = 1? y n y n te = 1? tcie = 1? y n re = 1? y n rdrf = 1? valid sci request no valid sci request
m68hc11 resets and interrupts motorola reference manual 5-21 the xirq input pin. the illegal opcode fetch interrupt is a non-maskable interrupt source intended to improve system integrity. although it performs like an interrupt, swi is an instruction rather than an asynchronous interrupt. the xirq input is an up- dated version of the non-maskable interrupt ( nmi) input of earlier mcus. 5.4.1 non-maskable interrupt request ( xirq) non-maskable interrupts are useful because they can always interrupt cpu operation. the most common use for such an interrupt is for very serious system problems, such as program runaway or power failure. the xirq mechanism over-comes two signifi- cant problems with an nmi input while retaining the important capabilities associated with a non-maskable source. the first nmi problem is as follows: what if an nmi is requested before the stack point- er has been initialized? if this request happens, the register stacking operation causes register values to be written to a random area of memory. if the stack pointer is point- ing to some unimplemented memory area or to a read-only area, there will be no way to return to the program in progress at the time of the interrupt. if the stack pointer is pointing at a data area in memory, the register values will be written over the data (thus corrupting it). since this situation is not desirable, the nmi had to be externally inhibit- ed after reset until the stack pointer could be initialized. the second nmi problem is as follows: what if the nmi signal bounces so that nmi is nested? if nesting occurs, the stack can be filled with several copies of the register val- ues, possibly filling the stack beyond its allotted space. nesting in this way would also cause excessive latency from the request until the resulting program actions are exe- cuted. the m68hc11 solves both these problems with the x bit in the ccr. the x bit is very similar to the i bit except that there are special restrictions on setting and clearing of the x bit. since x can only be cleared by a software instruction, the programmer has control over when the xirq input becomes enabled. the two software instructions that can clear the x bit are tap and rti (provided the stacked ccr value has a zero in the x bit position). the two hardware conditions that can set the x bit are system reset and the recognition of an xirq. immediately after any reset, the x bit is set; thus, xirq is inhibited. when software has established initial conditions, including setting the stack pointer, the x bit may be cleared with a tap instruction to enable xirq. these two steps overcome the first nmi problem. since software cannot set the x bit, the xirq can be considered a non- maskable source at this point. when an xirq occurs, the ccr value is stacked (with the x bit clear); the x bit is then automatically set to inhibit additional interrupts. this step overcomes the second nmi problem. when an rti instruction is executed, the ccr is restored to the stacked value (which had the x bit clear). a common miscon- ception is that the x bit can be set by executing an rti instruction with a one in the x bit position of the stacked ccr value. in reality, the x bit is implemented as a set-reset flip-flop rather than a d-type flip-flop. the set input is connected to the or of reset and xirq acknowledge. the reset input is connected to the and of a ccr write and data bit 6 equals zero. if an attempt is made to tap or unstack a one to the x bit, neither
motorola resets and interrupts m68hc11 5-22 reference manual the set nor the clear input to the x bit flip-flop will be activated, and the x bit will remain unchanged. the m68hc11 supports a stop mode where all clocks are stopped to reduce power consumption to a few microamps. recovery to active mode is accomplished by a reset or an interrupt ( irq or xirq). depending upon the state of the x bit in the ccr, the xirq input offers a choice of two recovery methods. if x is zero, xirq interrupts are enabled, and recovery leads to register stacking and normal interrupt service. if x is one, xirq interrupts are inhibited, but the xirq pin can still be used for recovery from the stop mode. rather than resuming operation with service of an interrupt ( xirq), the clocks start and processing resumes with the next opcode after the stop opcode. this technique can be thought of as a stop-continue mechanism. some m68hc11 mcus were manufactured with a subtle defect that can cause failure to properly recover from stop with an interrupt input ( irq or xirq). if the opcode im- mediately preceding the stop opcode came from column 4 or 5 of the opcode map, recovery was incorrect. column 4 and 5 opcodes are accumulator instructions, such as negate a (nega) or decrement b (decb), which seldom appear immediately be- fore a stop instruction; therefore, a long time elapsed before the problem was dis- covered. a simple nop instruction before the stop opcode assures proper recovery from stop in all cases. 5.4.2 illegal opcode fetch since not all possible opcodes or opcode sequences are defined, an illegal opcode de- tection circuit has been included. when an illegal opcode is detected, an interrupt is requested to the illegal opcode vector. the illegal opcode vector should never be left uninitialized. the stack pointer should be re-initialized as a result of an illegal opcode interrupt so repeated execution of illegal opcodes does not cause stack overruns. if the illegal opcode vector were left uninitialized, it could point to a memory location that contained an illegal opcode. in such a case, there would be an infinite loop of repeated illegal opcodes and an infinite stack overflow, which would cause the register contents to be stored to all memory addresses in a very short time. the illegal opcode trap mechanism works for all unimplemented opcodes on all four opcode-map pages. the address stacked as the return address for the illegal opcode interrupt is the address of the first byte of the illegal opcode. otherwise, it would be almost impossible to determine whether the illegal opcode had been one or two bytes. the stacked return address can be used as a pointer to the illegal opcode so the illegal opcode service routine can evaluate the offending opcode. the illegal opcode mechanism can be used to create a number of special-purpose in- structions that use otherwise illegal opcodes. when one of these opcodes is encoun- tered, the interrupt service routine can look up the special opcocde and perform some special task. the return address would need to be manually changed since it points to the illegal opcode rather than to the instruction that follows the illegal opcode. the test instruction (opcode $00) is a legal opcode in special test and bootstrap modes, but it is an especially offensive illegal opcode in normal operating modes. the
m68hc11 resets and interrupts motorola reference manual 5-23 illegal opcode detection logic treats the test opcode as illegal when the mcu is in normal operating modes and as legal in special test and bootstrap modes. 5.4.3 software interrupt the swi is executed in the same manner as other instructions and takes precedence over pending interrupts only if the other interrupts are masked (i and x bits in the ccr set). the swi instruction is executed in a manner similar to other maskable interrupts in that it sets the i bit, cpu registers are stacked, etc. swi is not inhibited by the global interrupt mask bits (x or i) in the ccr. note the swi instruction will not be fetched if any other interrupt is pend- ing. however, once an swi instruction begins, no other interrupt can be honored until the swi vector has been fetched. swi instructions are commonly used in debug monitors to transfer control from a user program to the debug monitor. for example, while operating under monitor control, a designer can specify a breakpoint at some address in the user program being de- bugged. the monitor will replace the users opcode at this address with the opcode for an swi instruction. when the users program is running and this swi opcode is en- countered, the monitor, recognizing that this is a breakpoint, will take control. the swi opcodes are usually placed into the users program just before the program is run, and these locations are restored to the original opcode when the debug monitor regains control. 5.5 maskable interrupts the remaining twenty interrupt sources in the MC68HC11a8 are subject to masking by a global interrupt mask bit (i bit in ccr). in addition to the global i bit, all of these sources except the external interrupt ( irq pin) are subject to local enable bits in con- trol registers. most interrupt sources in the m68hc11 have separate interrupt vectors; thus, there is usually no need for software to poll control registers to determine the cause of an interrupt. the maskable interrupt sources respond to a fixed-priority rela- tionship except that any one source can be dynamically elevated to the highest priority position of any maskable source. this subsection discusses the maskable interrupt structure rather than the specific in- terrupts from individual internal peripheral subsystems. the interrupts associated with the internal subsystems are discussed throughout this manual during the discussion of each peripheral system. 5.5.1 i bit in the condition code register the i bit in the ccr acts as a primary enable control for all maskable interrupts. when the i bit is set, interrupts can become pending but will not be honored. when the i bit is clear, interrupts are enabled to interrupt normal program flow when an interrupt source requests service. the i bit is set during reset to prevent interrupts from being honored until minimum sys-
motorola resets and interrupts m68hc11 5-24 reference manual tem initialization has been performed. part of this minimum initialization would be to load the stack pointer so it points to an appropriate area of ram. the i bit is also au- tomatically set during entry into any interrupt service routine to prevent an infinite source of interrupts from overwhelming the cpu. software can also set the interrupt mask bit to inhibit interrupts during sensitive operations. the i bit can be cleared by software instructions or during the execution of an rti in- struction. in most applications, the i bit remains set during interrupt service routines so other interrupts will not be honored until a current interrupt service routine finishes (i.e., nesting is not permitted). in more unusual applications, it is possible to allow nesting of interrupts by clearing the i bit during an interrupt service routine. since this proce- dure requires much expertise, it should not be attempted by a novice programmer. in some cases, worst-case interrupt latency can be reduced by allowing interrupt nesting, but usually the best procedure is to minimize the execution time of interrupt service routines. since the overhead associated with interrupt nesting usually violates this pro- cedure, nesting is not recommended. the operation of the i bit during service of an interrupt proceeds as follows. when an enabled interrupt occurs and the i bit is clear, the cpu completes the current instruc- tion and begins the interrupt response sequence. the current contents of the cpu reg- isters are pushed onto the stack (stored in stack ram). the register values are saved one byte at a time in the following order: pcl, pch, iyl, iyh, ixl, ixh, acca, accb, and ccr. after the ccr value is stacked, the i bit in the ccr is set to inhibit further interrupts. next, the vector for the highest priority pending interrupt is fetched, and pro- cessing continues with execution of the first instruction in the interrupt service routine. the last instruction in the interrupt service routine is the rti instruction. this instruc- tion causes the previously stacked register values to be loaded back into the registers in reverse order. since the program counter is restored to its pre-interrupt value, the next instruction executed will be the instruction that would have been executed if the interrupt had not occurred. a common error for new users is to put a set interrupt mask (sei) instruction at the beginning of an interrupt service routine and a clear interrupt mask (cli) instruction just before the rti instruction. these instructions should not be used in this way be- cause they are redundant. the automatic interrupt logic already sets the i bit on the way into an interrupt and clears the i bit during normal execution of the rti instruction. 5.5.2 special considerations for i-bit-related instructions there are some special conditions associated with the i bit that require additional con- sideration. the i bit is actually a sequential logic circuit rather than a simple flip-flop. when the i bit is set by an sei or a tap instruction, interrupts are inhibited immediate- ly. an interrupt occurring while an sei instruction is executing will not be honored until unless the i bit is later cleared. when the i bit is cleared by a cli or tap instruction, the actual clear operation is delayed for one bus cycle so the instruction following the cli or tap will always be executed. this procedure implies that the following loop can never be interrupted by a maskable interrupt:
m68hc11 resets and interrupts motorola reference manual 5-25 the reason for this delayed clear operation can be seen in the next instruction se- quence: if there were not a delay in clearing the i bit, it is possible the interrupt could be recog- nized between the cli and wai instructions. upon return from the interrupt service routine, the wai instruction would be executed, and the cpu would erroneously wait for the interrupt that was just serviced. during execution of an rti instruction, the first register to be restored from the stack is the ccr. in this situation, the one-cycle delay in clearing the i bit expires long before the rti instruction is finished; thus, a new interrupt sequence can be started even be- fore a single instruction of the interrupted program is executed. 5.6 interrupt request the maskable interrupt structure in the m68hc11 can be extended to additional exter- nal interrupting sources through the irq input. this subsection discusses the irq in- put as it relates to the interrupt structure. the alternate use of the irq pin as an eeprom programming voltage source during factory testing is discussed in 2.2.6 in- terrupt pins (xirq, irq) . although this subsection is primarily concerned with the irq pin, there are several ad- ditional mcu pins that can be used as interrupt inputs. the xirq pin provides for non- maskable interrupts. the main-timer input-capture pins (ic[3:1]) can be used as edge- sensitive interrupt inputs with separate controls for selecting the significant edge and separate interrupt vectors. the pulse accumulator input pin can also be used as an additional edge-sensitive interrupt. if the mcu is operating in single-chip mode, the strobe a (stra/as) pin is available as an edge-triggered interrupt input. though there is only one irq pin, these other pins allow an MC68HC11a8 to have up to seven in- terrupt pins. 5.6.1 selecting edge triggering or level triggering the default (most common) configuration for the irq pin in an m68hc11 application is a low-level-sensitive wired-or network. in less common applications, irq can be a low-going edge-sensitive input. the edge-sensitive configuration is less common be- cause it only allows a single interrupt source to use the irq pin; whereas, the level- sensitive configuration can accommodate many sources on the single irq pin. the irq select edge-sensitive only irqe bit in the option control register is used to se- lect the irq pin configuration (irqe = 0 for low level sensitive and irqe = 1 for low- going edge sensitive). the irqe control bit is time-protected, which means it can only loop cli enable interrupts sei disable interrupts bra loop repeat cli enable interrupts wai wait for an interrupt
motorola resets and interrupts m68hc11 5-26 reference manual be written once within the first 64 e-clock cycles after reset. irqe is cleared by default during reset. the interrupt sources within the mcu all operate as a wired-or level-sensitive net- work. when an event triggers an interrupt, a software-accessible interrupt flag is set, which (if enabled) causes a constant request for interrupt service. when software has recognized the interrupt, this flag is cleared, thus releasing the request for service. the flag bit acts as a static indication that service is required. if more than one interrupt source is connected to a single level-sensitive line, the line may remain asserted for several overlapping events from different sources, and the flag bits assure that all re- quests will be serviced. in an edge-sensitive network, the mcu is responsible for latching a request upon rec- ognition of a low-going edge at the interrupt input. this configuration is only capable of recognizing that an edge occurred (there is no software-accessible record to identify the requesting source); thus, the edge-sensitive configuration is appropriate only where a single source could have made the request. 5.6.2 sharing vector with handshake i/o interrupts because the irq vector is shared by the handshake i/o subsystem and the irq input pin, the handshake i/o functions can be rebuilt externally when the mcu is operating in expanded modes. while the mcu is in an expanded mode, 18 pins, which were used for the handshake i/o subsystem, become dedicated to the expansion bus. the mc68hc24 is a port replacement unit (pru) that rebuilds the handshake i/o func- tions. the mcu is specifically designed to treat the associated addresses as external locations while in expanded modes so that software sees no difference between an expanded system with a pru and an m68hc11 operating in single-chip mode. since the handshake i/o system uses the same vector as the irq pin, the pru can drive the irq pin of the mcu. even the interrupts for the handshake i/o system are faithfully emulated. the shared interrupt with irq solves most emulation problems for the pru; however, there are some difficulties in applications where irq is configured for edge-sensitive operation. in such a system, the pru is connected to the irq pin and to the users external interrupt source. the edge-sensitive configuration is not able to distinguish which source caused an interrupt. also, if an edge-triggered interrupt is generated by the external source while an interrupt is pending from the pru, the low level on the irq line prevents any new-edge from being detected. since the level-sensitive config- uration is more common for irq and since so many other pins can act as edge-sensi- tive interrupt inputs, this limitation should not be serious. 5.7 interrupts from internal peripheral subsystems the following paragraphs discuss common aspects of the interrupts generated by on- chip peripheral systems. the interrupt sources for on-chip peripheral systems are dis- cussed in greater detail in the sections for each peripheral system.
m68hc11 resets and interrupts motorola reference manual 5-27 5.7.1 inhibiting individual sources all on-chip interrupt sources have software-accessible control bits to enable the inter- rupt sources on an individual basis. each source has a flag bit, which indicates service is required, and an interrupt enable bit, which enables the flag to generate hardware interrupt requests. the programmer decides which sources will be used to generate interrupts and which will be handled by software polling rather than by interrupts. the global interrupt mask (i bit in ccr) can be used to inhibit all maskable interrupts. 5.7.2 clearing interrupt status flag bits the method for clearing the interrupt status flags varies from one system to another. detailed explanations of the clearing requirements for each flag are provided in the sections for each on-chip peripheral system. timer system interrupt flags are cleared by writing a logic one to the flag bit positions to be cleared. this action is explicit and is intended to prevent these flags from being cleared unintentionally. the most straightforward way to accomplish clearing is to load an accumulator with an immediate value (with ones in the bit positions corresponding to a flag bit(s) to be cleared) and then write this value to the status register. other in- struction sequences can be used to clear these timer flag bits, including bit manipula- tion instructions. several instruction sequences for clearing timer flags are discussed in detail in 10.2.4 tips for clearing timer flags . 5.7.3 automatic clearing mechanisms on some flags for some of the interrupt sources, such as the parallel i/o interrupt and the sci inter- rupts, the flags are automatically cleared during the normal course of responding to the interrupt requests. for example, the rdrf flag in the sci system is cleared by the automatic clearing mechanism consisting of a read of the sci status register while rdrf is set, followed by a read of the sci data register. the normal response to an rdrf interrupt request would be to read the sci status register to check for receive errors, then read the received data from the sci data register. these two steps satisfy the automatic clearing mechanism without requiring any special instructions. in unusual cases, a programmer must take special care not to unintentionally trigger the automatic clearing mechanisms. the following guidelines help to avoid such prob- lems. reads of registers containing status flags should be minimized. ideally, the sta- tus register should be read only during the course of servicing the interrupt, and the status flag should be read only once for each time the interrupt is requested. if more than one part of the service routine uses different bits in the status register, the register should be read only once, and a copy should be kept in ram or in a cpu register for further use. the cycle-by-cycle operation of instructions that access status registers may also present another problem. some instructions are read-modify-write instruc- tions even though the read information is not actually needed for the instruction. for example, the clear (clr) instruction performs a read of the operand address even though the value read is irrelevant. a situation could arise where the sci data register is cleared to transmit a $00 value via the sci transmitter. though it is not obvious, this action can satisfy the second step of the automatic clearing mechanism for the rdrf flag because clearing of the sci transmit data register involves a read of the sci data
motorola resets and interrupts m68hc11 5-28 reference manual register prior to the write of $00.
m68hc11 central processing unit motorola reference manual 6-1 section 6 central processing unit this section discusses the m68hc11 central processing unit (cpu), which is respon- sible for executing all software instructions in their programmed sequence. the m68hc11 cpu can execute all m6800 and m6801 instructions (source and object- code compatible) and more than 90 new instruction opcodes. since more than 256 in- struction opcodes exist, a multiple-page opcode map is used in which some new in- structions are specified by a page-select prebyte before the opcode byte. the architecture of the m68hc11 cpu causes all peripheral, i/o, and memory loca- tions to be treated identically as locations in the 64-kbyte memory map. thus, there are no special instructions for i/o that are separate from those used for memory. this technique is sometimes called "memory-mapped i/o". in addition, there is no execu- tion-time penalty for accessing an operand from an external memory location as op- posed to a location within the mcu. the m68hc11 cpu offers several new capabilities when compared to the earlier m6801 and m6800 cpus. the biggest change is the addition of a second 16-bit index register (y). powerful, new bit-manipulation instructions are now included, allowing manipulation of any bit or combination of bits in any memory location in the 64-kbyte address space. two new 16-bit by 16-bit divide instructions are included. exchange instructions allow the contents of either index register to be exchanged with the con- tents of the 16-bit double accumulator. finally, several instructions have been upgrad- ed to make full 16-bit arithmetic operations even easier than before. this section discusses the cpu architecture, addressing modes, and the instruction set (by instruction types). examples are included to show efficient ways of using this architecture and instruction set. to condense this section, detailed explanations of each instruction are included in appendix a instruction set details . these explanations include detailed cycle-by-cycle bus activity and boolean expressions for condition code bits. this section should be used to gain a general understanding of the cpu and instruction set. 6.1 programmers model figure 6-1 shows the programmers model of the m68hc11 cpu. the cpu registers are an integral part of the cpu and are not addressed as if they were memory loca- tions. each of these registers is discussed in the subsequent paragraphs. 6.1.1 accumulators (a, b, and d) accumulators a and b are general-purpose 8-bit accumulators used to hold operands and results of arithmetic calculations or data manipulations. some instructions treat the combination of these two 8-bit accumulators as a 16-bit double accumulator (ac- cumulator d).
motorola central processing unit m68hc11 6-2 reference manual figure 6-1 m68hc11 programmers model most operations can use accumulator a or b interchangeably; however, there are a few notable exceptions. the abx and aby instructions add the contents of the 8-bit accumulator b to the contents of the 16-bit index register x or y, and there are no equivalent instructions that use a instead of b. the tap and tpa instructions are used to transfer data from accumulator a to the condition code register or from the condition code register to accumulator a; however, there are no equivalent instructions that use b rather than a. the decimal adjust accumulator a (daa) instruction is used after bi- nary-coded decimal (bcd) arithmetic operations, and there is no equivalent bcd in- struction to adjust b. finally, the add, subtract, and compare instructions involving both a and b (aba, sba, and cba) only operate in one direction; therefore, it is im- portant to plan ahead so the correct operand will be in the correct accumulator. 6.1.2 index registers (x and y) the 16-bit index registers x and y are used for indexed addressing mode. in the in- dexed addressing mode, the contents of a 16-bit index register are added to an 8-bit offset, which is included as part of the instruction, to form the effective address of the operand to be used in the instruction. in most cases, instructions involving index reg- ister y take one extra byte of object code and one extra cycle of execution time com- pared to the equivalent instruction using index register x. the second index register is especially useful for moves and in cases where operands from two separate tables are involved in a calculation. in the earlier m6800 and m6801, the programmer had to store the index to some temporary location so the second index value could be loaded into the index register. 8-bit accumulators a & b 70 70 15 0 ab d ix iy sp pc 70 c v z n i h x s or 16-bit double accumulator d index register x index register y stack pointer program counter carry/borrow from msb overflow zero negative i-interrupt mask half carry (from bit 3) x-interrupt mask stop disable condition codes
m68hc11 central processing unit motorola reference manual 6-3 the abx and aby instructions along with increment and decrement instructions allow some arithmetic operations on the index registers, but, in some cases, more powerful calculations are needed. the exchange instructions, xgdx and xgdy, offer a very simple way to load an index value into the 16-bit double accumulator, which has more powerful arithmetic capabilities than the index registers themselves. it is very common to load one of the index registers with the beginning address of the internal register space (usually $1000), which allows the indexed addressing mode to be used to access any of the internal i/o and control registers. indexed addressing re- quires fewer bytes of object code than the corresponding instruction using extended addressing. perhaps a more important argument for using indexed addressing to ac- cess register space is that bit-manipulation instructions are available for indexed ad- dressing but not for extended addressing. 6.1.3 stack pointer (sp) the m68hc11 cpu automatically supports a program stack. this stack may be locat- ed anywhere in the 64-kbyte address space and may be any size up to the amount of memory available in the system. normally, the stack pointer register is initialized by one of the very first instructions in an application program. each time a byte is pushed onto the stack, the stack pointer is automatically decremented, and each time a byte is pulled off the stack, the stack pointer is automatically incremented. at any given time, the stack pointer register holds the 16-bit address of the next free location on the stack. the stack is used for subroutine calls, interrupts, and for temporary storage of data values. when a subroutine is called by a jump to subroutine (jsr) or branch to subroutine (bsr) instruction, the address of the next instruction after the jsr or bsr is automat- ically pushed onto the stack (low half first). when the subroutine is finished, a return from subroutine (rts) instruction is executed. the rts causes the previously stacked return address to be pulled off the stack, and execution continues at this recovered re- turn address. whenever an interrupt occurs (provided it is not masked), the current instruction fin- ishes normally, the address of the next instruction (the current value in the program counter) is pushed onto the stack, all of the cpu registers are pushed onto the stack, and execution continues at the address specified by the vector for the highest priority pending interrupt. after completing the interrupt service routine, a return from interrupt (rti) instruction is executed. the rti instruction causes the saved registers to be pulled off the stack in reverse order, and program execution resumes as if there had been no interruption. another common use for the stack is for temporary storage of register values. a simple example would be a subroutine using accumulator a. the user could push accumula- tor a onto the stack when entering the subroutine and pull it off the stack just before leaving the subroutine. this method is a simple way to assure a register(s) will be the same after returning from the subroutine as it was before starting the subroutine. the most important aspect of the stack is that it is completely automatic. a program-
motorola central processing unit m68hc11 6-4 reference manual mer does not normally have to be concerned about the stack other than to be sure that it is pointing at usable random-access memory (ram) and that there is sufficient space. to assure sufficient space, the user would need to know the maximum depth of subroutine or interrupt nesting possible in the particular application. there are a few less common uses for the stack. the stack can be used to pass pa- rameters to a subprogram, which is fairly common in high-level language compilers but is often overlooked by assembly-language programmers. there are two advantag- es of this technique over specific assignment of temporary or variable locations. first, the memory locations are only needed for the time the subprogram is being executed; they can be used for something else when the subprogram is completed. second, this feature makes the subprogram re-entrant so that an interrupting program could call the same subprogram with a different set of values without disturbing the interrupted use of the subprogram. in unusual cases, a programmer may want to look at or even manipulate something that is on the stack, which should only be attempted by an experienced programmer because it requires a detailed understanding of how the stack operates. monitor pro- grams like buffalo sometimes place items on a stack manually and then perform an rti instruction to go to a user program. this technique is an odd use of the stack and rti instruction because an rti would normally correspond to a previous interrupt. 6.1.4 program counter (pc) the program counter is a 16-bit register that holds the address of the next instruction to be executed. 6.1.5 condition code register (ccr) this register contains five status indicators, two interrupt masking bits, and a stop disable bit. the register is named for the five status bits since that is the major use of the register. in the earlier m6800 and m6801 cpus, there was no x interrupt mask and no stop disable control in this register. the five status flags reflect the results of arithmetic and other operations of the cpu as it performs instructions. the five flags are half carry (h), negative (n), zero (z), overflow (v), and carry/borrow (c). the half-carry flag, which is used only for bcd arithmetic operations (see 6.3.1.2 arithmetic operations ), is only affected by the add accumulators a and b (aba), add, and add with carry (adc) addition instructions (21 opcodes total). the n, z, v, and c status bits allow for branching based on the results of a previous operation. simple branches are included for either state of any of these four bits. both signed and unsigned versions of branches are provided for the condi- tions <, , =, 1 , 3 , or >. the h bit indicates a carry from bit 3 during an addition operation. this status indicator allows the cpu to adjust the result of an 8-bit bcd addition so it is in correct bcd for- mat, even though the add was a binary operation. this h bit, which is only updated by the aba, add, and adc instructions, is used by the daa instruction to compensate the result in accumulator a to correct bcd format.
m68hc11 central processing unit motorola reference manual 6-5 the n bit reflects the state of the most significant bit (msb) of a result. for twos com- plement, a number is negative when the msb is set and positive when the msb is ze- ro. the n bit has uses other than in twos-complement operations. by assigning an often tested flag bit to the msb of a register or memory location, the user can test this bit by loading an accumulator. the z bit is set when all bits of the result are zeros. compare instructions do an internal implied subtraction, and the condition codes, including z, reflect the results of that sub- traction. a few operations (inx, dex, iny, and dey) affect the z bit and no other con- dition flags. for these operations, the user can only determine = and 1 . the v bit is used to indicate if a twos-complement overflow has occurred as a result of the operation. the c bit is normally used to indicate if a carry from an addition or a borrow has oc- curred as a result of a subtraction. the c bit also acts as an error flag for multiply and divide operations. shift and rotate instructions operate with and through the carry bit to facilitate multiple-word shift operations. in the m68hc11 cpu, condition codes are automatically updated by almost all instruc- tions; thus, it is rare to execute any extra instructions to specifically update the condi- tion codes. for example, the load accumulator a (ldaa) and store accumulator a (staa) instructions automatically set or clear the n, z, and v condition code flags. (in some other architectures, very few instructions affect the condition code bits; thus, it takes two instructions to load and test a variable.) the challenge in a motorola proces- sor lies in finding instructions that specifically do not alter the condition codes in rare cases where that is desirable. the most important instructions that do not alter condi- tions codes are the pushes, pulls, add b to x (abx), add b to y (aby), and 16-bit trans- fers and exchanges. it is always a good idea to refer to an instruction set summary such as the pocket guide (MC68HC11a8rg/ad) to check which condition codes are affected by a particular instruction. the stop disable (s) bit is used to allow or disallow the stop instruction. some us- ers consider the stop instruction dangerous because it causes the oscillator to stop; however, the user can set the s bit in the ccr to disallow the stop instruction. if the stop instruction is encountered by the cpu while the s bit is set, it will be treated like a no-operation (nop) instruction, and processing continues to the next instruction. the interrupt request ( irq) mask (i bit) is a global mask that disables all maskable in- terrupt sources. while the i bit is set, interrupts can become pending and are remem- bered, but cpu operation continues uninterrupted until the i bit is cleared. after any reset, the i bit is set by default and can only be cleared by a software instruction. when any interrupt occurs, the i bit is automatically set after the registers are stacked but be- fore the interrupt vector is fetched. after the interrupt has been serviced, an rti in- struction is normally executed, restoring the registers to the values that were present before the interrupt occurred. normally, the i bit would be zero after an rti was exe- cuted. although interrupts can be re-enabled within an interrupt service routine, to do so is unusual because nesting of interrupts becomes possible, which requires much more programming care than single-level interrupts and seldom improves system per-
motorola central processing unit m68hc11 6-6 reference manual formance. the xirq mask (x bit) is used to disable interrupts from the xirq pin. after any reset, x is set by default and can only be cleared by a software instruction. when xirq is recognized, the x bit (and i bit) are automatically set after the registers are stacked but before the interrupt vector is fetched. after the interrupt has been serviced, an rti in- struction is normally executed, causing the registers to be restored to the values that were present before the interrupt occurred. it is logical to assume the x bit was clear before the interrupt; thus, the x bit would be zero after the rti was executed. although xirq can be re-enabled within an interrupt service routine, to do so is unusual be- cause nesting of interrupts becomes possible, which requires much more program- ming care than single-level interrupts. 6.2 addressing modes in the m68hc11 cpu, six addressing modes can be used to reference memory: im- mediate, direct, extended, indexed (with either of two 16-bit index registers and an 8- bit offset), inherent, and relative. some instructions require an additional byte (a pre- byte) before the opcode to accommodate a multiple-page opcode map. each of the addressing modes (except inherent) results in an internally generated, double-byte value referred to as the effective address. this value, which is the result of a statement operand field, is the value that appears on the address bus during the memory reference portion of the instruction. the addressing mode is an implicit part of every m68hc11 instruction. bit-manipulation instructions actually employ two or three addressing modes during execution but are classified by the addressing mode used to access the primary oper- and. all bit-manipulation instructions use immediate addressing to fetch a bit mask, and branch variations use relative addressing mode to determine a branch destina- tion. the following paragraphs provide a description of each addressing mode. in these de- scriptions, effective address is used to indicate the memory address from which the argument is fetched or stored or from which execution is to proceed. 6.2.1 immediate (imm) in the immediate addressing mode, the actual argument is contained in the byte(s) im- mediately following the instruction in which the number of bytes matches the size of the register. these instructions are two, three, or four (if prebyte is required) bytes. machine-code byte(s) that follow the opcode are the value of the statement rather than the address of a value. in this case, the effective address of the instruction is specified by the character # sign and implicitly points to the byte following the opcode. the im- mediate value is limited to either one or two bytes, depending on the size of the regis- ter involved in the instruction. examples of several assembly-language statements using the immediate addressing mode are shown. symbols and expression used in these statements are defined immediately after the examples.
m68hc11 central processing unit motorola reference manual 6-7 the first three statements are assembler directives that set up values to be used in the remaining statements. the remaining nine statements are examples of immediate ad- dressing. the value of each statement operand field appears in byte(s) immediately following the opcode. the operand field for immediate addressing begins with the character # sign. the character # sign is used by the assembler to detect the immedi- ate mode of addressing. a very common programming error is to forget this character # sign. machine code label operation operand comments cat equ 7 cat same as 7 org $1000 set location counter regs equ * addr(regs) is $1000 86 16 ldaa #22 decimal 22 t acca ($16) c8 34 eorb #$34 xor ($34,accb) t accb 81 24 cmpa #%100100 right aligned binary 86 07 ldaa #cat 7 t acca cc 12 34 ldd #$1234 cc 00 07 ldd #7 7 t acca:accb 86 12 ldaa #@22 octal 86 41 ldaa #a ascii ce 10 00 ldx #regs addr(regs) t x a variety of symbols and expressions can be used following the character # sign. since not all assemblers use the same rules of syntax and special characters, the user should refer to the documentation for the particular assembler that will be used. char- acter prefixes used in the previous example statements are defined as follows: 6.2.2 extended (ext) in the extended addressing mode, the effective address of the instruction appears ex- plicitly in the two bytes following the opcode. therefore, the length of most instructions using the extended addressing mode is three bytes: one for the opcode and two for the effective address. the last two bytes of the instruction contain the absolute ad- dress of the operand. these instructions are three or four (if prebyte is required) bytes: one or two for the opcode and two for the effective address. instructions from the sec- ond, third, and fourth opcode map pages require a page-select prebyte prior to the op- code byte. only four extended addressing mode instructions involving index register y require this extra prebyte. examples of assembly-language statements that use extended addressing mode are grouped with direct addressing mode examples and appear after the discussion of the direct addressing mode. prefix definition none decimal $ hexadecimal @ octal % binary single ascii character
motorola central processing unit m68hc11 6-8 reference manual 6.2.3 direct (dir) in the direct addressing mode, the least significant byte of the effective address of the instruction appears in the byte following the opcode. the high-order byte of the effec- tive address is assumed to be $00 and is not included as an instruction byte (saves program memory space and execution time). this fact limits the use of direct address- ing mode to operands in the $0000C$00ff area of memory (called the direct page). the direct addressing mode is sometimes called zero-page addressing mode. the length of most instructions using the direct addressing mode is two bytes: one for the opcode and one for the effective address. instructions from the second, third, and fourth opcode-map pages require a page-select prebyte prior to the opcode byte. only four direct addressing mode instructions involving index register y require this extra prebyte. direct addressing allows the user to access $0000C$00ff, using instructions that take one less byte of program memory space than the equivalent instructions using extend- ed addressing. by eliminating the additional memory access, execution time is re- duced by one cycle. in the course of a large program, this savings can be substantial. for most applications, the default memory map of the microcontroller unit (mcu), which places internal random-access memory (ram) in the $0000C$00ff area, is a good choice because the designer can assign these locations to frequently referenced data variables. in some mcu applications, it is desirable to locate the internal registers in this premium memory space. this arrangement might be desirable in an i/o-inten- sive application in which the program space savings are important or in the case of some very critical timing requirement in which the extra cycle for extended addressing mode is undesirable. in the m68hc11 mcu, software can configure the memory map so that internal ram, and/or internal registers, or external memory space can occupy these addresses (see 3.3.1 ram and i/o mapping register (init) . there are some instructions that provide for extended addressing mode but not direct addressing mode. these instructions, which are members of a group called read-mod- ify-write instructions, operate directly on memory (opcodes $40C$7f except jump (jmp) and test for zero or minus (tst) on all opcode pages) and have the following form: m t m the increment memory byte (inc), decrement memory byte (dec), clear memory byte (clr), and ones complement memory byte (com) instructions are members of this group, and each supports extended addressing mode but not direct addressing mode. the following example shows the direct and extended addressing modes. machine code label operation operand comments b3 00 12 subd cat fwd ref to cat cat equ $12 define cat=$12 93 12 subd cat bkwd ref to cat 7f 00 12 clr cat extended only in the previous example, the first reference to the cat label is a forward reference, and the assembler selected the extended addressing mode. the second reference,
m68hc11 central processing unit motorola reference manual 6-9 which is a backward reference, enabled the assembler to know the symbol value when processing the statement, and the assembler selected the direct addressing mode. the last reference to cat is also a backward reference to a symbol in the direct ad- dressing area, but the extended addressing mode was selected because there is no direct addressing mode variation of that particular instruction. some assemblers allow the direct or extended addressing modes to be forced (by preceding the operand field with < or >, respectively), even when other conditions would suggest the other mode. 6.2.4 indexed (indx, indy) in the indexed addressing mode, either index register x or y is used in calculating the effective address. in this case, the effective address is variable and depends on the current contents of index register x or y and a fixed, 8-bit, unsigned offset contained in the instruction. this addressing mode can be used to reference any memory loca- tion in the 64-kbyte address space. these instructions are usually two or three bytes (if prebyte is required) the opcode and the 8-bit offset. in microprocessor-based systems, instructions usually reside in read-only memory (rom). therefore, the offset in the instruction should be considered a fixed value that is determined at assembly time rather than during program execution. the use of dy- namic single-byte offsets is facilitated with the use of the add accumulator b to index register x (abx) instruction. more complex address calculations are aided by the arith- metic capability of the 16-bit accumulator d and the xgdx and xgdy instructions. if no offset is specified or desired, the machine code will contain $00 in the offset byte. the offset is an unsigned single-byte value that, when added to the current value in the index register, yields the effective address of the operand, leaving the index regis- ter unchanged. because the offset byte is unsigned, only positive offsets in the range 0C255 can be specified. to use the indexed addressing mode to access on-chip reg- isters in the MC68HC11a8, it is best to initialize the index register to the starting ad- dress of the register block (usually $1000) and use an 8-bit offset ($00C$3f) in the instructions that access registers. this method is preferred over loading the index reg- ister with the 16-bit address of a register and then specifying a zero offset in the in- struction. this latter method requires modification of the index register for each register access; whereas, the former method does not. examples of the indexed addressing mode are shown (ea indicates effective ad- dress): machine code label operation operand comments e3 00 addd x ea=(x) e3 00 addd ,x ea=(x) e3 00 addd 0,x ea=(x) e3 04 addd 4,x ea=(x)+4 cat equ 7 define cat=7 e3 07 addd cat,x ea=(x)+7 e3 22 addd $22,x ea=(x)+$22 e3 22 addd cat*8/2+6,x ea=(x)+(cat*8 ? 2+6) bit-manipulation instructions support direct and indexed addressing modes but not ex-
motorola central processing unit m68hc11 6-10 reference manual tended addressing mode. the indexed addressing mode becomes very important for these instructions because the direct addressing mode only permits access to the first 256 memory locations; whereas, the indexed addressing mode allows access to any memory location in the 64-kbyte memory map. the second index register (y) improves the efficiency of move operations and opera- tions involving data from more than one table. most instructions involving index regis- ter y require two-byte opcodes, thus requiring one extra byte of program memory space and one extra cycle of execution time compared to the equivalent index register x instruction. 6.2.5 inherent (inh) in the inherent addressing mode, everything needed to execute the instruction is in- herently known by the cpu. the operands (if any) are cpu registers and thus are not fetched from memory. these instructions are usually one or two bytes. many m68hc11 mcu instructions use one or more registers as operands. for in- stance, the aba instruction causes the cpu to add the contents of accumulators a and b and place the result in accumulator a. the incb instruction causes the contents of accumulator b to be incremented by one. similarly, the inx instruction causes the index register x to be incremented by one. these three assembly-language state- ments are examples of the inherent addressing mode: machine code label operation operand comments 1b aba a+b t a 5c incb b+1 t b 08 inx x+1 t x 6.2.6 relative (rel) the relative addressing mode is used only for branch instructions. branch instructions, other than the branching versions of bit-manipulation instructions, generate two ma- chine code bytes: one for the opcode and one for the relative offset. because it is de- sirable to branch in either direction, the offset byte is a signed twos-complement offset with a range of C128 to +127 bytes (with respect to the address of the instruction im- mediately following the branch instruction). if the branch condition is true, the contents of the 8-bit signed byte following the opcode (offset) are added to the contents of the program counter to form the effective branch address; otherwise, control proceeds to the instruction immediately following the branch instruction. the offset byte is always the last byte of a branch instruction. if the offset byte is zero, execution will proceed to the instruction immediately following the branch instruction, regardless of the test involved. a branch always (bra) instruction with an offset of $fe will result in an infinite loop back to itself. direct or indexed x addressing mode branch if bit clear (brclr) and branch if bit set (brset) instructions are four-byte instruc- tions; therefore, an offset byte of $fc will cause the instruction to execute repeatedly until the bit test becomes false. indexed y addressing mode brclr and brset in- structions are five-byte instructions; thus, an offset byte of $fb will cause the instruc- tion to execute repeatedly until the bit test becomes false.
m68hc11 central processing unit motorola reference manual 6-11 examples of the relative addressing mode are shown in the following assembly-lan- guage statements: machine code label operation operand comments 20 00 there bra where forward branch 22 fc where bhi there backward branch 24 04 bcc lbcc l-o-n-g bcc 27 fe hang beq hang branch to self 27 fe beq * "*" means "here" 7e 10 00 lbcc jmp $1000 8d f7 bsr hang 6.3 m68hc11 instruction set this section is intended to explain the basic capabilities and organization of the in- struction set. for this discussion, the instruction set is divided into functional groups of instructions. some instructions will appear in more than one functional group. for ex- ample, transfer accumulator a to ccr (tap) appears in the ccr group and in the load/store/transfer subgroup of accumulator/memory instructions. detailed explana- tions of each instruction are given in appendix a instruction set details . to expand the number of instructions used in the m68hc11 cpu, a prebyte mecha- nism that affects certain instructions has been added. most of the instructions affected are associated with index register y. instructions that do not require a prebyte reside in page 1 of the opcode map. instructions requiring a prebyte reside in pages 2, 3, and 4 of the opcode map. the opcode-map prebyte codes are $18 for page 2, $1a for page 3, and $cd for page 4. a prebyte code applies only to the opcode immediately follow- ing it. that is, all instructions are assumed to be single-byte opcodes unless the first byte of the instruction happens to correspond to one of the three prebyte codes rather than a page 1 opcode. 6.3.1 accumulator and memory instructions most of these instructions use two operands. one operand is either an accumulator or an index register; whereas, the second operand is usually obtained from memory us- ing one of the addressing modes discussed earlier. these accumulator memory in- structions can be divided into six subgroups: 1) loads, stores, and transfers, 2) arithmetic operations, 3) multiply and divide, 4) logical operations, 5) data testing and bit manipulation, and 6) shifts and rotates. these instructions are discussed in the fol- lowing tables and paragraphs. 6.3.1.1 loads, stores, and transfers almost all mcu activities involve transferring data from memories or peripherals into the cpu or transferring results from the cpu into memory or i/o devices. the load, store, and transfer instructions associated with the accumulators are summarized in the following table. there are additional load, store, push, and pull instructions asso- ciated with the index registers and stack pointer register (see 6.3.2 stack and index register instructions ).
motorola central processing unit m68hc11 6-12 reference manual 6.3.1.2 arithmetic operations this group of instructions supports arithmetic operations on a variety of operands; 8- and 16-bit operations are supported directly and can easily be extended to support multiple-word operands. twos-complement (signed) and binary (unsigned) opera- tions are supported directly. bcd arithmetic is supported by following normal arith- metic instruction sequences, using the daa instruction, which restores results to bcd format. compare instructions perform a subtract within the cpu to update the condi- tion code bits without altering either operand. although test instructions are provided, they are seldom needed since almost all other operations automatically update the condition code bits. function mnemonic imm dir ext indx indy inh clear memory byte clr x x x clear accumulator a clra x clear accumulator b clrb x load accumulator a ldaa x x x x x load accumulator b ldab x x x x x load double accumulator d ldd x x x x x pull a from stack pula x pull b from stack pulb x push a onto stack psha x push b onto stack pshb x store accumulator a staa x x x x x store accumulator b stab x x x x x store double accumulator d std x x x x x transfer a to b tab x transfer a to ccr tap x transfer b to a tba x transfer ccr to a tpa x exchange d with x xgdx x exchange d with y egdy x
m68hc11 central processing unit motorola reference manual 6-13 6.3.1.3 multiply and divide one multiply and two divide instructions are provided. the 8-bit by 8-bit multiply pro- duces a 16-bit result. the integer divide (idiv) performs a 16-bit by 16-bit divide, pro- ducing a 16-bit result and a 16-bit remainder. the fractional divide (fdiv) divides a 16- bit numerator by a larger 16-bit denominator, producing a 16bit result (a binary weight- ed fraction between 0 and 0.99998) and a 16-bit remainder. fdiv can be used to fur- ther resolve the remainder from an idiv or fdiv operation. function mnemonic imm dir ext indx indy inh add accumulators aba x add accumulator b to x abx x add accumulator b to y aby x add with carry to a adca x x x x x add with carry to b adcb x x x x x add memory to a adda x x x x x add memory to b addb x x x x x add memory to d (16 bit) addd x x x x x compare a to b cba x compare a to memory cmpa x x x x x compare b to memory cmpb x x x x x compare d to memory (16 bit) cpd x x x x x decimal adjust a (for bcd) daa x decrement memory byte dec x x x decrement accumulator a deca x decrement accumulator b decb x increment memory byte inc x x x increment accumulator a inca x increment accumulator b incb x twos complement memory byte neg x x x twos complement accumulator a nega twos complement accumulator b negb subtract with carry from a sbca x x x x x subtract with carry from b sbcb x x x x x subtract memory from a suba x x x x x subtract memory from b subb x x x x x subtract memory from d (16 bit) subd x x x x x test for zero or minus tst x x x test for zero or minus a tsta x test for zero or minus b tstb x function mnemonic inh multiply (a x b t d) mul x fractional divide (d ? x t x; r t d) fdiv x integer divide (d ? x t x; r t d) idiv x
motorola central processing unit m68hc11 6-14 reference manual 6.3.1.4 logical operations this group of instructions is used to perform the boolean logical operations and, in- clusive or, exclusive or, and ones complement. 6.3.1.5 data testing and bit manipulation this group of instructions is used to operate on operands as small as a single bit, but these instructions can also operate on any combination of bits within any 8-bit location in the 64-kbyte memory space. the bit test (bita or bitb) instructions perform an and operation within the cpu to update condition code bits without altering either op- erand. the bset and bclr instructions read the operand, manipulate selected bits within the operand, and write the result back to the operand address. some care is re- quired when read-modify-write instructions such as bset and bclr are used on i/o and control register locations because the physical location read is not always the same as the location written. 6.3.1.6 shifts and rotates all the shift and rotate functions in the m68hc11 cpu involve the carry bit in the ccr in addition to the 8- or 16-bit operand in the instruction, which permits easy extension to multiple-word operands. also, by setting or clearing the carry bit before a shift or ro- tate instruction, the programmer can easily control what will be shifted into the opened end of an operand. the arithmetic shift right (asr) instruction maintains the original value of the msb of the operand, which facilitates manipulation of twos-complement (signed) numbers. function mnemon- ic imm dir ext indx indy inh and a with memory anda xxxxx and b with memory andb xxxxx bit(s) test a with memory bita xxxxx bit(s) test b with memory bitb xxxxx ones complement memory byte com x x x ones complement a coma x ones complement b comb x or a with memory (exclusive) eora xxxxx or b with memory (exclusive) eorb xxxxx or a with memory (inclusive) oraa xxxxx or b with memory (inclusive) orab xxxxx function mnemonic imm dir ext indx indy bit(s) test a with memory bita xxxxx bit(s) test b with memory bitb xxxxx clear bit(s) in memory bclr x x x set bit(s) in memory bset x x x branch if bit(s) clear brclr x x x branch if bit(s) set brset x x x
m68hc11 central processing unit motorola reference manual 6-15 the logical-left-shift instructions are shown in parentheses because there is no differ- ence between an arithmetic and a logical left shift. both mnemonics are recognized by the assembler as equivalent, but having both instruction mnemonics makes some pro- grams easier to read. 6.3.2 stack and index register instructions the following table summarizes the instructions available for the 16-bit index registers (x and y) and the 16-bit stack pointer. function mnemonic imm dm ext indx indy inh arithmetic shift left memory asl x x x arithmetic shift left a asla x arithmetic shift left b aslb x arithmetic shift left double asld x arithmetic shift right memory asr x x x arithmetic shift right a asra x arithmetic shift right b asrb x (logical shift left memory) (lsl) x x x (logical shift left a) (lsla) x (logical shift left b) (lslb) x (logical shift left double) (lsld) x logical shift right memory lsr x x x logical shift right a lsra x logical shift right b lsrb x logical shift right d lsrd x rotate left memory rol x x x rotate left a rola x rotate left b rolb x rotate right memory ror x x x rotate right a rora x rotate right b rorb x
motorola central processing unit m68hc11 6-16 reference manual the exchange d with x (xgdx) and exchange d with y (xgdy) provide a simple way of transferring a pointer value from a 16-bit index register to accumulator d, which has more powerful 16-bit arithmetic capabilities than the 16-bit index registers. since these are bidirectional exchanges, the original value of accumulator d is automatically pre- served in the index register while the pointer is being manipulated in accumulator d. when pointer calculations are finished, another exchange simultaneously updates the index register and restores accumulator d to its former value. the transfers between an index register and the stack pointer deserve additional com- ment. the stack pointer always points at the next free location on the stack as opposed to the last item that was pushed onto the stack. the usual reason for transferring the stack pointer value into an index register is to allow indexed addressing access to in- formation that was formerly pushed onto the stack. in such cases, the address pointed to by the stack pointer is of no value since nothing has yet been stored at that location. this fact explains why the value in the stack pointer is incremented during transfers to an index register. there is a corresponding decrement of a 16-bit value as it is trans- ferred from an index register to the stack pointer. function mnemonic imm dir ext indx indy inh add accumulator b to x abx x add accumulator b to y aby x compare x to memory (16 bit) cpx x x x x x compare y to memory (16 bit) cpy x x x x x decrement stack pointer des x decrement index register x dex x decrement index register y dey x increment stack pointer ins x increment index register x inx x increment index register y iny x load index register x ldx x x x x x load index register y ldy x x x x x load stack pointer lds x x x x x pull x from stack pulx x pull y from stack puly x push x onto stack pshx x push y onto stack pshy x store index register x stx x x x x x store index register y sty x x x x x store stack pointer sts x x x x x transfer sp to x tsx x transfer sp to y tsy x transfer x to sp txs x transfer y to sp tys x exchange d with x xgdx x exchange d with y xgdy x
m68hc11 central processing unit motorola reference manual 6-17 6.3.3 condition code register instructions these instructions allow a programmer to manipulate bits in the ccr. initially, it may appear that there should be a set and a clear instruction for each of the eight bits in the ccr; however, these instructions are present for only three of the eight bits (c, i, and v). upon closer consideration, good reasons exist for not including the set and clear instructions for the other five bits. the stop disable (s) bit is an unusual case because this bit is intended to lock out the stop instruction for those who view it as an undesirable function in their application. providing set and clear instructions for this bit would make it easier to enable stop when it was not wanted or disable stop when it was wanted. the tap instruction provides a way to change the s bit but reduces the chance of an undesirable change to s because the value of accumulator a at the time the tap instruction is executed determines whether the s bit will actually change. the xirq mask (x bit) is another unusual case. the definition of this bit specifically states that software shall not be allowed to change x from zero to one; in fact, this change is even prohibited by hardware logic. this feature immediately eliminates a need for a set x instruction. for arguments similar to those used for the s bit, the tap instruction is preferred over a clear x instruction to clear x because tap makes it a little less likely that x will become cleared before the programmer intended. the half-carry (h) bit needs no set or clear instructions because this condition code bit is only used by the daa instruction to adjust the result of a bcd add or subtract. since the h bit is not used as a test condition for any branches, it would not be useful to be able to set or clear this bit. this leaves only the negative (n) and zero (z) condition code bits. in contrast to s, x, and h, it is often useful to be able to easily set or clear these flag bits. a clear accu- mulator instruction, such as clrb, will clear the n and set the z condition code bits. the load instruction, ;ldaa#$80, causes n to be set and z to be cleared. since there are so many simple instructions that can set or clear n and z, it is not necessary to provide specific set and clear instructions for n and z in this group. 6.3.4 program control instructions this group of instructions, which is used to control the flow of a program rather than to function mnemonic inh clear carry bit clc x clear interrupt mask bit cli x clear overflow bit clv x set carry bit sec x set interrupt mask bit sei x set overflow bit sev x transfer a to ccr tap x transfer ccr to a tpa x
motorola central processing unit m68hc11 6-18 reference manual manipulate data, has been divided into five subgroups: 1) branches, 2) jumps, 3) sub- routine calls and returns, 4) interrupt handling, and 5) miscellaneous, 6.3.4.1 branches these instructions allow the cpu to make decisions based on the contents of the con- dition code bits. all decision blocks in a flow chart would correspond to one of the con- ditional branch instructions summarized in the following table. the limited range of branches (C128/+127 locations) is more than adequate for most (but not all) situations. in cases where this range is too short, a jump instruction must be used. for every branch, there is a branch for the opposite condition; thus, it is sim- ple to replace a branch having an out-of-range destination with a sequence consisting of the opposite branch around a jump to the out-of-range destination. for example, if a program contained the following instruction bhi tinbuk2 unsigned > where tinbuk2 was out of the C128/+127 location range, the following instruction se- quence could be substituted: bls around unsigned jmp tinbuk2 still go to tinbuk2 if > around equ * function mnemonic rel dir indx indy comments branch if carry clear bcc x c = 0 ? branch if carry set bcs x c = 1 ? branch if equal zero beq x z = 1 ? branch if greater than or equal bge x signed 3 branch if greater than bgt x signed > branch if higher bhi x unsigned > branch if higher or same (same as bcc) bhs x unsigned 3 branch if less than or equal ble x signed branch if lower (same as bcs) blo x unsigned < branch if lower or same bls x unsigned branch if less than blt x signed < branch if minus bmi x n= 1 ? branch if not equal bne x z = 0 ? branch if plus bpl x n = 0 ? branch if bit(s) clear in memory byte brclr x x x bit manipulation branch never brn x 3-cycle nop branch if bit(s) set in memory byte brset x x x bit manipulation branch if overflow clear bvc x v = 0 ? branch if overflow set bvs x v = 1 ?
m68hc11 central processing unit motorola reference manual 6-19 6.3.4.2 jumps the jump instruction allows control to be passed to any address in the 64-kbyte mem- ory map. 6.3.4.3 subroutine calls and returns (bsr, jsr, rts) these instructions provide an easy way to divide a programming task into manageable blocks called subroutines. the cpu automates the process of remembering the ad- dress in the main program where processing should resume after the subroutine is fin- ished. this address is automatically pushed onto the stack when the subroutine is called and is pulled off the stack during the rts instruction that ends the subroutine. 6.3.4.4 interrupt handling (rti, swi, wai) this group of instructions is related to interrupt operations. the software interrupt (swi) instruction is similar to a jsr instruction, except the con- tents of all working cpu registers are saved on the stack rather than just the return address. swi is unusual in that it is requested by the software program as opposed to other interrupts that are requested asynchronously to the executing program. wait for interrupt (wai) has two main purposes. wai is executed to place the mcu in a reduced power-consumption standby state (wait mode) until some interrupt occurs. it is also used to reduce the latency time to some important interrupt. the reduction of latency occurs because the time-consuming task of storing the cpu registers on the stack is performed as soon as the wai instruction begins executing. when the inter- rupt finally occurs, the cpu is ready to fetch the appropriate vector so the delay asso- ciated with register stacking is eliminated from latency calculations. 6.3.4.5 miscellaneous (nop, stop, test) nop, which can be used to introduce a small time delay into the flow of a program, is often useful in meeting the timing requirements of slow peripherals. by incorporating nop instructions into loops, longer delays can be produced. function mnemonic dir ext indx indy inh jump jmp xxxx function mnemonic rel dir ext indx indy inh branch to subroutine bsr x jump to subroutine jsr x x x x return from subroutine rts x function mnemonic inh return from interrupt rti x software interrupt swi x wait for interrupt wai x
motorola central processing unit m68hc11 6-20 reference manual during debugging, it is common to replace various instructions with nop opcodes to effectively remove an unwanted instruction without having to rearrange the rest of the program. by using the memory modify function of a debug monitor, the instruction can easily be removed and restored to see the effect. occasionally, a programmer is faced with the problem of fine-tuning the delays through various paths in his program. in such cases, it is sometimes useful to use a branch never (brn) instruction as a three-cycle nop. it is also possible to fine-tune execution time by choosing alternate addressing-mode variations of instructions to change the execution time of an instruction sequence without changing the programs function. stop is an unusual instruction because it causes the oscillator and all mcu clocks to freeze. this frozen state is called stop mode, and power consumption is dramatically reduced in this mode. the operation of this instruction is also dependent upon the s condition code bit because the stop mode is not appropriate for all applications. if s is one, the stop instruction is treated as a nop instruction, and processing continues to the next instruction. the test instruction is used only during factory testing and is treated as an illegal op- code in normal operating modes of the mcu. this instruction causes unusual behavior on the address bus (counts backwards), which prevents its use in any normal system. function mnemonic inh no operation (2-cycle delay) nop x stop clocks stop x test test x
m68hc11 parallel input/output motorola reference manual 7-1 section 7 parallel input/output this section describes parallel i/o operations in the MC68HC11a8, which includes port reads and writes as well as strobe and handshake operations on ports b and c. the section begins with an overview, followed by detailed descriptions of each port and the handshake i/o subsystem. a number of schemes for efficient use of parallel i/o on the MC68HC11a8 are included. 7.1 parallel i/o overview the MC68HC11a8 has a total of 40 i/o pins, which will be discussed in 7.3 detailed i/o pin descriptions . all these pins are shared between general-purpose i/o usage and at least one other on-chip peripheral function. although the following paragraphs are primarily concerned with the general-purpose i/o capabilities of these pins, some important interactions with the alternate functions will be discussed. shared functions of port a include general-purpose i/o, the main timer system, and the pulse accumulator system. port a has three fixed-direction input pins, four fixed- direction output pins, and one bidirectional pin. the direction of the pa7 pin is con- trolled by the data direction register a bit 7 control bit (ddra7) in the pulse accumu- lator control (pactl) register. port a data is read from and written to the porta register. meaningful data may be read from port a even when the pins are configured for an alternate timer or pulse accumulator function. data written to port a does not directly affect port a pins configured for an alternate timer output function, but the data is remembered in an internal latch so that, if the alternate function is disabled later, the last data written to port a will be driven out of the associated output pin. ports b and c and the strobe a (stra) and strobe b (strb) pins should be consid- ered together because their function depends on the basic operating mode of the MC68HC11a8. when the microcontroller unit (mcu) is operating in a single-chip mode, these 18 pins are used for general-purpose i/o and for the handshake i/o sub- system. when the mcu is operating in an expanded mode, these pins are used for a multiplexed address/data bus. the handshake and general-purpose i/o functions, which are lost in the expanded mode, can be regained by use of the mc68hc24 port replacement unit. special care was taken in designing both these parts so that soft- ware could be developed on an expanded system using these two parts and then later be mask programmed into the read-only memory (rom) of an MC68HC11a8, which will be used in single-chip mode. although care was taken to assure that the expanded system with an mc68hc24 would work exactly like the MC68HC11a8 in single-chip mode, there are a few subtle differences. for the vast majority of applications, these differences are irrelevant. for the benefit of those rare cases where a problem could arise, the differences will be explained in the detailed descriptions of these ports and pins in 7.3 detailed i/o pin descriptions .
motorola parallel input/output m68hc11 7-2 reference manual port b is a general-purpose, 8-bit, fixed-direction output port. writes to the port b reg- ister (portb) cause data to be latched and driven out of the port b pins. reads of portb return the last data that was written to port b. when the handshake i/o sub- system is operating in simple strobed mode, writes to portb automatically cause a pulse on the strb output pin. the simple strobe mode is selected by the handshake (hnds) control bit equal to zero in the parallel i/o control (pioc) register. port c is a general-purpose, 8-bit, bidirectional i/o port. the primary direction of data flow at each port c pin is independently controlled by a corresponding bit in the data direction control register for port c (ddrc). in addition to normal i/o functions at port c, there is an independent, 8-bit, parallel latch that captures port c data whenever a selected active edge is detected on the stra input pin. reads of portcl return the contents of this port c latch; whereas, reads of portc return the current data from port c. writes to either portc or portcl cause the written data to be driven out of port c output pins; however, portcl writes also trigger output handshake sequenc- es; portc writes do not. writes to port c pins not configured as outputs do not cause data to be driven out of those pins, but the data is remembered in internal latches; thus, if the pins later become outputs, the last data written to portc or portcl will be driven out the port c pins. port c can be configured for wired-or operation by setting the port c wired-or mode (cwom) control bit in the pioc register. this procedure disables the p-channel pull- up drivers of port c output pins and allows port c pins to be directly connected to each other or to other open-drain-type pins. in this configuration, there is no danger of de- structive conflicts if two output drivers try to drive the same node at the same time. as with any open-drain line, an external pull-up resistor is required. whenever the handshake i/o subsystem is configured for a full-handshake mode, port c is used for parallel data input or output. stra is a strobe input pin that causes port c data to be captured when a selected edge is detected. in the three-state variation of full-output handshake, the stra pin also acts as an output enable control to force port c pins to be driven outputs while stra is in its selected state. strb is a strobe output pin that can be used in a pulsed or interlocked configuration. in the pulsed configura- tion, some action in the handshake i/o subsystem initiates strb, which then stays active for two e-clock cycles before reverting to its inactive state. in the interlocked configuration, strb is initiated by one action in the handshake subsystem and termi- nated by a separate action. the final major element of the handshake subsystem is the strobe a flag (staf) status bit. staf is always set upon recognition of the select- ed edge at the stra pin, but the action that clears staf depends on the handshake mode. there is a more detailed description of the handshake i/o subsystem in 7.4 handshake i/o subsystem . port d is a general-purpose, 6-bit, bidirectional data port. two port d pins are alter- nately used by the asynchronous serial communications interface (sci) subsystem. the remaining four port d pins are alternately used by the synchronous serial periph- eral interface (spi) subsystem. the primary direction of data flow at each of the port d pins is selected by a corresponding bit in the data direction register for port d (ddrd). port d can be configured for wired-or operation by setting the port d wired-
m68hc11 parallel input/output motorola reference manual 7-3 or mode control bit (dwom) in the spi control register (spcr). port e is an 8-bit, fixed-direction input port. port e pins alternately function as analog- to-digital (a/d) converter channel inputs. port e input buffers are specially designed so they will not draw excessive power-supply currents when their inputs are driven by intermediate levels. 7.2 parallel i/o register and control bit explanations figure 7-1 shows all the registers and control bits concerned with the discussion of parallel i/o in the following paragraphs. the registers are shown in the order they ap- pear in the memory map of the MC68HC11a8 because this order is significant in the case of double-byte reads and writes. figure 7-2 shows a number of registers and control bits mentioned in 7.3 detailed i/o pin descriptions . these control bits are used to enable other on-chip peripheral subsystems to use the i/o pins. these regis- ters, which are shown here for reference, are discussed throughout this manual. bit positions labeled with a zero rather than a name indicate unimplemented bits that al- ways read as zeros. figure 7-1 parallel i/o registers and control bits bit 7 654321 bit 0 $1000 bit 7 bit 0 porta $1002 staf stai cwom hnds oin pls ega invb pioc $1003 bit 7 bit 0 portc $1004 bit 7 bit 0 portb $1009 0 0 bit 5 bit 0 ddrd $1026 ddra7 paen pamod pedge 0 0 rtr1 rtr0 pactl $1028 spie spe dwom mstr cpol cpha spr1 spr0 spcr
motorola parallel input/output m68hc11 7-4 reference manual figure 7-2 pin logic registers and control bits the addresses for the registers in figure 7-1 and figure 7-2 are in the form "$10xx" where xx is a hexadecimal number between 00 and 3f. the "1" indicates that the most significant hexadecimal digit is a variable controlled by user software. the ram and i/ o mapping (init) register is used to specify the location of internal registers and ram. by default, ram is located from $0000 to $00ff, and registers are located from $1000 to $103f at reset. the user can elect to move either one or both of these resources by writing a new value into the init register within 64 bus cycles after reset. the init reg- ister is discussed in greater detail in section 4 on-chip memory . the bit-manipulation instructions in the MC68HC11a8 can only be used in zero-page or indexed addressing modes. to use indexed addressing mode to access internal registers, the user would first set either the x or y index register equal to the base ad- dress of the registers (usually $1000). to use the zero-page addressing mode, the user would first remap the internal registers by writing to the init register during reset initialization. 7.2.1 port registers reads of port registers will return either the level at the pin itself or the logic state at a point inside the output pin buffer. usually, the state of the corresponding ddr bit will determine which of these points will be used for a read if a choice exists. refer to 7.3 detailed i/o pin descriptions for more specific information. writes to port registers cause the written data to be latched and driven out of the corresponding port output pins. if a port pin is capable of being an output, this written information is latched even if the pin is not configured as a port output at the time of the write. if the pin is subsequently reconfigured to be a port output, the output pin will be driven with the last data that was written to that port. writes to port bits that are fixed-direction input pins have no mean- ing or effect. portcl, a special port register associated with port c, is part of the handshake i/o subsystem. reads of this address return data from an 8-bit port c latch. the inputs to bit 7 654321 bit 0 $100b foc1 foc2 foc3 foc4 foc5 0 0 0 cforc $100c oc1m7 oc1m6 oc1m5 oc1m4 oc1m3 0 0 0 oc1m $100d oc1d7 oc1d6 oc1d5 oc1d4 oc1d3 0 0 0 oc1d $1020 om2 ol2 om3 ol3 om4 ol4 om5 ol5 tctl1 $103d ram3 ram2 ram1 ram0 reg3 reg2 reg1 reg0 init
m68hc11 parallel input/output motorola reference manual 7-5 this port c latch are connected to the port c pins, and the latches are clocked when a selected edge is recognized at the stra pin. contrary to first impressions, writes to portcl do not change the data in the port c latch register. instead, writes to portcl are used as an alternate way to write data to port c. in addition to writing data to the port c output latches, writes to portcl also trigger special handshake sequences in the handshake i/o subsystem, which allows some port c pins to be treated as general-purpose outputs while others are being used for full-handshake outputs. a user would write data to portc to change the non-handshake pins in port c. to change the data on a full-handshake pin of port c, the user would write to portcl. 7.2.2 data direction registers these registers and control bits are used to specify the primary direction of data flow at each bidirectional port pin. a zero in a data direction register (ddr) bit disables the output buffer for that pin so the pin is configured as an input. when a ddr bit is set to one, it enables the output driver for the associated port pin so the pin is configured as an output. during reset, internal logic in the MC68HC11a8 forces all ddr bits to zero; thus, all bidirectional i/o pins are configured as high-impedance inputs until they are reconfigured by software. in some cases, an enabled on-chip subsystem can override the ddr bit and force a pin to be an input or an output. for example, it is illogical for the txd pin to be config- ured as an input while the sci transmitter is using this pin. whenever the sci trans- mitter subsystem is enabled, the txd pin is configured as an output, regardless of what the corresponding ddrd bit is. there is a subtle benefit to this override besides the obvious savings gained by not having to write to the ddr. depending on the over- all system attached to the txd pin, it may be desirable for this pin to revert to a specific driven logic level or to a high-impedance condition. if the ddr bit is zero, the txd pin will revert to a general-purpose, high-impedance input pin when not being used by the transmitter. if the ddr bit is one, the txd pin will revert to a general-purpose output pin, and the driven logic level will reflect what was last written to bit 1 of port d. in other cases, the ddr bits continue to affect the configuration of a port pin even after an on-chip subsystem has been enabled to use the pin. consider the spi bidirectional data pins master in/slave out (miso) and master out/slave in (mosi). although the MC68HC11a8 spi system is capable of full-duplex operation, some synchronous se- rial protocols are configured for half-duplex operation with a single, bidirectional data line. for the MC68HC11a8 to operate in such a system, it must be able to selectively disable its mosi and miso outputs. the state of a ddr bit influences the source of data when the corresponding port bit is read. in general, when a pin is configured as an input, reads return the logic level from the pin itself. when a pin is configured as an output, reads return a value corre- sponding to the level at the inside of the output buffer for that pin. this fact is especially important in the case of pins configured for wired-or operation or for the three-state variation of full-output handshake at port c. in these cases, the value at the pin itself does not necessarily reflect the value last written to the port; therefore, it is important to read the level inside the output buffer rather than the level at the pin.
motorola parallel input/output m68hc11 7-6 reference manual 7.3 detailed i/o pin descriptions the logic associated with each of the i/o pins is described in detail in the following paragraphs. all circuitry directly connected to a pin is shown exactly as it is implement- ed in the MC68HC11a8. logic not directly connected to a pin is functionally accurate, but the drawings have been simplified. figure 7-3 shows some of the symbols used in the logic drawings, which may not be familiar to all readers. the protection devices, which are intended to protect the MC68HC11a8 from high-voltage transients, have no effect while pins are within the v ss to v dd range. although transmission gates are ac- tually full cmos bidirectional switches, they are shown in simplified form in the logic diagrams. half flip-flops (hffs) are latches that are transparent while the clock input is high and are latched while the clock input is low. set and reset inputs are optional on hffs. any name enclosed in a rectangle indicates a control bit within the MC68HC11a8. numbers in square brackets are references for the text descriptions. figure 7-3 special symbols used in pin logic diagrams ddra7 [3] reference number control bit protection thick-field protection device transmission gate half flip-flop rs q q c d d c q q s hff r
m68hc11 parallel input/output motorola reference manual 7-7 7.3.1 port a the eight port a pins can be independently configured for general-purpose i/o or for timer or pulse accumulator functions. the following paragraphs describe the pin logic for port a pins. the idealized timing for critical port a signals is presented in 7.3.1.4 port a idealized timing . 7.3.1.1 pa[2:0] (ic[3:1]) pin logic refer to figure 7-4 for the following discussion. the cross-coupled nand circuit with four associated inverters is a hysteresis buffer. hysteresis is provided by sizing invert- er [1] so its switch point is higher than normal and by sizing inverter [2] so its switch point is lower than normal. figure 7-4 pa[2:0] (ic[3:1]) pin logic starting with zero on the pin, a slowly rising signal causes inverter [2] to switch so that the r signal goes to an inactive-high state. as the input continues to rise, inverter [1] switches, causing a low s, which causes the cross-coupled nand latch to set q high and clear q low. the low q reinforces the s signal so that, even if noise causes invert- er [1] to switch back to s equals one, the cross-coupled latch will not reset. conversely, starting with one on the pin, a slowly failing signal causes inverter [1] to switch, causing the s signal to be placed in an inactive-high state. as the input contin- ues to fall, inverter [2] switches, causing a low r. this low r resets the cross-coupled nand latch, setting q high and clearing q low. the low q reinforces the r signal so that, even if noise causes inverter [2] to switch back to r equals one, the cross-cou- pled latch will not become set. for bits 0, 1, and 2, port a reads return the buffered states of the corresponding pins. port a reads are completely independent of timer input-capture functions. 7.3.1.2 pa[6:3] (oc[5:2]) pin logic refer to figure 7-5 for the following discussion. for bits 3, 4, 5, and 6, port a reads return the logic state from a point inside the output pin buffer. during a port a read, transmission gate [1] is enabled to couple logic state [2] to the internal data bus. pin [3] protection timer input-capture edge detect q q pa2Cpa0 (ic1Cic3) d2Cd0 rporta r s [2] [1] ic1Cic3 trigger
motorola parallel input/output m68hc11 7-8 reference manual inverter [2] is driven by a head-to-tail cheater latch. the feedback inverter [3] in this cheater latch is sized to be overridden by transmission gate [4], [5], or [6]. these three transmission gates correspond to the three possible sources of data for these port a pins as follows. general-purpose port a outputs come through transmission gate [4] from hff latch [7]. output compares 5 through 2 (oc[5:2]) affect their corresponding port a pin via transmission gate [6]; output compare 1 (oc1) can affect these port a pins via transmission gate [5]. control gate [8] enables general-purpose port a outputs during ptaclk when no tim- er function is enabled to control this pin. ptaclk is an internal clock signal that syn- chronizes port a pin changes to the falling edge of e. oc1 is enabled when the corresponding oc1mx bit is one, which disables control gate [8] and enables control gate [9]. the oc[5:2] functions are enabled to control their corresponding port a pin by the omx:olx bits not equal to 0:0. when omx:olx are not 0:0, control gate [8] is disabled and control gate [10] is enabled. control gate [9] allows oc1 to affect this port a pin. when the corresponding oc1mx control bit is one, control gate [9] is enabled. the ptaclk clock signal acts as a strobe. when there is a successful oc1 compare (oc1cmp) or when oc1 is forced by foc1 equals one, control gate [9] enables transmission gate [5], which causes the corresponding oc1dx state to be transferred to cheater latch [3]. nand gate [11] pro- vides a disable to control gate [10] so that if oc1 and another output compare simul- taneously attempt to change the same port a pin, oc1 will override. control gate [10] is enabled by the corresponding omx:olx control bits not equal to 0:0. when there is a successful output compare x (ocxcmp) or when ocx is forced by focx equals one, control gate [10] enables transmission gate [6] and momentarily disables transmission gate [12]. transmission gate [12] transfers the previous port a pin state to cheater latch [14]. cheater latch [14] holds the previous pin state stable for logic [13] while transmission gate [12] is disabled and transmission gate [6] is enabled. set-reset (s/r) latch [13] and associated logic is used to determine the next timer out- put state that would result from a successful ocx compare. this next timer output state is determined by the states of the associated omx and olx control bits and the previous port a pin state. 7.3.1.3 pa7 (oc1, pai) pin logic refer to figure 7-6 for the following discussion. hysteresis buffer [1] was previously described in 7.3.1.1 pa[2:0] (ic[3:1]) pin logic . reads of port a bit 7 always return the buffered state of the pa7 pin. for this bidirectional i/o pin, the state of the corre- sponding ddr control bit has no effect on the source of the data for the read. during a port a read, transmission gate [2] is enabled so the buffered state of the pa7 pin is driven onto the internal data bus.
m68hc11 parallel input/output motorola reference manual 7-9 figure 7-5 pa[6:3] (oc[5:2]) pin logic q q r s [12] [13] [6] [9] [5] [10] [14] [11] [8] [7] [1] [3] [4] [2] disable toggle clear set 1 1 0 1 1 0 0 0 olx olx ol2 om2 ol3 om3 ol4 om4 ol5 om5 next timer out state previous timer out state pa6Cpa3 (oc2Coc5) focx x=5,4,3,2 ocxcmp x=5,4,3,2 ptaclk foc1 x=5,4,3,2 oc1cmp x=5,4,3,2 rst wporta d6Cd3 rporta d c q q hffr r v dd protection pin n p oc1dx oc1mx
motorola parallel input/output m68hc11 7-10 reference manual figure 7-6 pa7 (oc1, pai) pin logic output buffer [3] is enabled when ddra7 is one. when ddra7 is zero, the n- and p- channel drivers are disabled so the pa7 pin acts as a high-impedance input. data for the pa7 pin is held in cheater latch [4]. transmission gates [5] and [6] correspond to the two possible sources of output data for the pa7 pin. when the oc1m7 control bit is zero, control gate [9] is disabled and control gate [8] is enabled. control gate [8] enables transmission gate [5] so general-purpose output data from hff [7] is transferred to cheater latch [4]. a write to port a causes data to be written into hff [7], which is cleared to zero during reset. when the oc1m7 control bit is one, control gate [8] is disabled and control gate [9] is enabled. while control gate [9] is enabled, a successful oc1 compare (oc1cmp) or a force oc1 (foc1) will enable transmission gate [6]. transmission gate [6] causes the oc1d7 state to be transferred to cheater latch [4]. q q d7 rporta r s [2] [1] [5] [7] [6] [3] [4] pa7 (pai) rst wporta oc1cmp d c q q hffr r v dd protection pin n p ptaclk oc1m7 foc1 [9] [8] oc1d7 ddra7 to pulse accumulator
m68hc11 parallel input/output motorola reference manual 7-11 7.3.1.4 port a idealized timing figure 7-7 shows the idealized timing for important port a control signals. this timing diagram, which does not consider any propagation delays, cannot be used as a sub- stitute for data-sheet timing specifications. this information is useful for understanding the basis for data-sheet timing specifications so timing information can be extrapolated for bus frequencies other than that used for the data sheet. figure 7-7 idealized port a timing on a port a read, the rporta signal enables transmission gates driving port a data onto the internal data bus. after the rporta signal is negated, data is held stable on the self-latching internal data bus. the central processing unit (cpu) actually requires this data to be valid for a setup and hold time around the rising edge of the internal ph2 clock signal. all operations that can cause changes to the port a output pins (except ddra7 control bit changes) are synchronized to the falling edge of the e clock. changes to ddra7 cause port a pins to change state at the falling edge of the internal ph2 clock. 7.3.2 port b the eight port b pins are fixed-direction output pins. when the MC68HC11a8 is oper- ating in an expanded mode, port b is used for high-order address outputs. in single- chip modes, port b is used for general-purpose output or for simple strobe output. the following paragraphs describe the port b pin logic and the idealized timing for selected port b signals. new port a data valid data required at cpu write to port a read from port a ph2 (internal) extal as ptaclk port a input rporta port a output wporta port a output pins control bit changes for bits: oc1mx, oc1dx, omx, olx, ddra7, focx e
motorola parallel input/output m68hc11 7-12 reference manual when the MC68HC11a8 is operating in an expanded mode, reads and writes to the port b address are treated as external accesses to allow port b functions to be emu- lated with external logic. the mc68hc24 port replacement unit (pru) duplicates the general-purpose and handshake i/o functions of ports b and c and the stra and strb pins. the mc68hc24 connects to the multiplexed address/data bus of the MC68HC11a8. 7.3.2.1 port b pin logic refer to figure 7-8 for the following discussion. reads of port b return the logic state from a point inside the output pin buffer. during reads of port b, transmission gate [1] is enabled by the rportb signal to couple logic state [2] to the internal data bus. the rportb signal is not asserted for port b reads in expanded modes since port b is an external address in that case. figure 7-8 port b pin logic in single-chip modes, the mode a (mda) control bit is zero, which enables and gate [3] and disables and gate [4]. the internal data bus is coupled through and gate [3] and clocked into hff [5] by the write port b (wportb) signal. the output of hff [5] is buffered and driven out the port b pins. in single-chip modes, hff [5] is set to one by and gate [6] during reset, which results in logic zero at the port b pins. in expanded modes, the mda control bit is one, enabling and gate [4] and disabling and gate [3], which couples high-order addresses to hff [5]. in expanded modes, hff [5] is transparent while address strobe (as) is high and latched while as is low. the output of hff [5] is buffered and driven out the port b pins. [5] [1] [2] pb7Cpb0 expanded as single chip wportb v dd protection pin n p mda q d c q s hffs [3] [4] [6] rst a15Ca8 d7Cd0 rportb
m68hc11 parallel input/output motorola reference manual 7-13 7.3.2.2 port b idealized timing figure 7-9 shows the idealized timing for important port b control signals. this timing diagram, which does not consider any propagation delays, cannot be used as a sub- stitute for data-sheet timing specifications. this information is useful for understanding the basis for data-sheet timing specifications so timing information can be extrapolated for bus frequencies other than that used for the data sheet. figure 7-9 idealized port b timing on a port b read, the rportb signal enables transmission gates, which drive port b data onto the internal data bus. there is no case where port b data can change in the same cycle in which a port b read is occurring. port b writes cause changes to the port b output pins at the falling edge of the internal ph2 clock. this edge corresponds to the middle of the e-clock high time. although this section is not specifically concerned with expanded-mode operation of port b, it is included here for reference. a more detailed discussion of the expansion bus is included in 2.6 typical expanded-mode-system connections . port b logic provides a full one-eight-cycle hold time on the high-order addresses relative to the falling edge of e. 7.3.2.3 special considerations for port b on mc68hc24 pru the external pru does not have access to the internal ph2 clock of the new port b data valid data required at cpu write to port b read from port b ph2 (internal) extal as port b input (single-chip mode) rportb port b output (single-chip mode) wportb port b pins e new port b data port b pins (mc68hc24 only) expanded mode port b pins as (repeated) high order address
motorola parallel input/output m68hc11 7-14 reference manual MC68HC11a8; therefore, slight differences exist in the timing of port b, port c, stra, and strb activities. see figure 7-9 for differences in timing for writes to port b of the MC68HC11a8 in single-chip mode as compared to writes to port b of the mc68hc24. 7.3.3 r/ w (strb) pin when the MC68HC11a8 is operating in an expanded mode, this pin acts as the read/ write (r/ w) bus control signal. when the MC68HC11a8 is operating in a single-chip mode, this pin acts as the strb output signal for the handshake i/o subsystem. the mc68hc24 can be used to regain the strb functions when the mcu is operating in an expanded mode. 7.3.3.1 r/ w (strb) pin logic refer to figure 7-10 for the following discussion. when the MC68HC11a8 is operat- ing in an expanded mode, the mda control bit is one. a one on mda disables trans- mission gate [2] and enables transmission gate [1], which, in turn, couples the output of hff [3] to the pin output buffer. hff [3] is transparent when as is high and latched when as is low, which gives r/ w the same timing as a high-order address line at port b and assures a long hold time on r/ w relative to the falling edge of e. r/ w and the expansion bus are described more fully in 2.6 typical expanded-mode-system connections . when the MC68HC11a8 is operating in a single-chip mode, mda is low, disabling transmission gate [1] and enabling transmission gate [2]. transmission gates [4] and [5] further select whether the q or q of cross-coupled latch [6] will be coupled to the strb pin. when the invert strobe b (invb) control bit in the pioc register is zero, the q of cross-coupled latch [6] is coupled to the strb pin, and strb signals are active low. when the invb control bit is one, the q of cross-coupled latch [6] is coupled to the strb pin and strb signals are active high.
m68hc11 parallel input/output motorola reference manual 7-15 figure 7-10 r/ w (strb) pin logic the start strobe b ( startstrb) is an active-low signal from the handshake i/o sub- system. the conditions that enable strobe b depend on the strobe or handshake mode in effect. the strobe and handshake modes are controlled by the state of the hnds and output/input (oin) control bits in the pioc register. when hnds is zero, the sim- ple strobe mode is selected, and the state of the oin control bit is ignored. in simple strobe mode, startstrb is asserted at the rising edge of the internal ph2 clock fol- lowing a write to the portb register. this time corresponds to the center of the e low time following the write to port b. when hnds is one and oin is zero, full-input hand- shake is selected. in full-input handshake mode, startstrb is asserted at the rising edge of the internal ph2 clock following a read of the portcl register. this time cor- responds to the center of the e low time following the read of port c latched data. when hnds and oin are one, full-output handshake is selected. in full-output hand- shake mode, startstrb is asserted at the rising edge of the internal ph2 clock fol- lowing a write to the portcl register. this time corresponds to the center of the e low time following the write to port c at portcl address. the end strobe b (endstrb) is an active-low signal from the handshake i/o sub- system. three possible conditions can cause the endstrb to be asserted. if the hnds bit is zero or if the pulse (pls) control bit is one, endstrb is asserted exactly two full e-clock periods after startstrb was asserted. this configuration corre- sponds to the simple strobe mode or a full-handshake mode where strobe b is config- ured for pulsed-mode operation. the second condition causing endstrb to be asserted corresponds to the full-handshake modes where strobe b has been config- [2] r/ w (strb) v dd protection pin n p mda q d c q hff r/ w (internal) as startstrb endstrb [3] [1] invb invb q q [4] [5] [6]
motorola parallel input/output m68hc11 7-16 reference manual ured for interlocked operation by pls equal zero. in this case, the endstrb signal is asserted at the next ph2 rising edge after the selected active edge is detected at the stra input pin. the internal ph2 rising edge corresponds to the center of the e low time. the third condition that can cause endstrb to be asserted is included to avoid a problem if strobe b is changed from interlocked operation to pulsed operation while strobe b is active. if pls is written to one while hnds is a one, the endstrb signal is asserted so the strobe b signal will be terminated at the next ph2 rising edge, which corresponds to the center of the e low time following the cycle where pioc was written with hnds and pls equal to one. 7.3.3.2 special considerations for strb on mc68hc24 pru because the external pru does not have access to the internal ph2 clock of the MC68HC11a8, slight differences exist in the timing of port b, port c, stra, and strb activities. in the mc68hc24, edges on strobe b occur one-quarter e cycle later than they would in the MC68HC11a8 in single-chip mode. in the case of full-handshake in- terlocked mode, strobe b will be terminated on the next rising edge of e after a strobe a edge is detected. the mc68hc24 has a synchronizer on the strobe a input, which is clocked by as; thus, the worst-case delay from an edge on strobe a to a response on strobe b is one and one-eighth e cycles rather than one e cycle (MC68HC11a8). because the implementation of the strobe b logic in the mc68hc24 is slightly different than that in the MC68HC11a8, the third condition that could terminate a strobe b sig- nal was not included in the mc68hc24. since changing from interlocked operation to pulsed operation in the middle of a transaction is not normal, this subtle difference should not concern most users. 7.3.4 port c port c is the most complex port on the MC68HC11a8 because it can act as general- purpose bidirectional i/o, full-input or full-output handshake i/o, or as a time-multi- plexed address/data bus port. due to the complexity of the port c pin logic, expanded and single-chip modes of operation will be discussed separately. the following para- graphs explain the logic associated with port c pins and the idealized timing of select- ed signals. although this section is not specifically concerned with expanded-mode operation of port c, it is included for reference. a more detailed discussion of the expansion bus is included in 2.6 typical expanded-mode-system connections . 7.3.4.1 port c pin logic for expanded modes in expanded modes, port c is a time-multiplexed address/data bus. during the first half of a cycle, addresses are driven out of port c. during the second half of the cycle, data is either written out of port c or read into port c. refer to figure 7-11 for the following discussion. pin output buffer [1] can be enabled or disabled by the ptctsc signal. this signal is driven to zero when address or data information needs to be driven out of port c. when ptctsc is one, the output buffer is disabled so port c pins become high-im-
m68hc11 parallel input/output motorola reference manual 7-17 pedance input pins (e.g., while data is being read into port c). figure 7-11 port c expanded mode pin logic information to be driven out of port c can come from either transmission gate [2] or [3]. when the address enable (addren) signal is one, transmission gate [2] is enabled to couple address lines addr[7:0] to the output buffer of their associated port c pin. when the write data enable (wdaten) signal is one, transmission gate [3] is enabled to couple data lines data[7:0] to the output buffer of their associated port c pin. in the read direction, data comes from the port c pins to strobe input buffers [6]. data from buffers [6] is then clocked into hff [5] during the e high time. data is coupled to the cpu through transmission gate [4] when the read data enable (rdaten) signal is one. since the cpu actually uses the read data during the one-quarter cycle after e goes low, hff [5] also provides a level of synchronization for the incoming data. in normal operation, the stop/wait ( stopwait) signal is logic one, which enables buff- ers [6]. when the mcu is in the stop/wait low-power modes, the stopwait is zero, and buffers [6] are disabled. while buffers [6] are disabled, intermediate or switching levels on the port c pins will not cause the relatively high currents normally expected for cmos inputs. 7.3.4.2 summary of port c idealized expanded-mode timing port c expanded-mode timing includes four types of bus cycles. write cycles look pc7Cpc0 v dd protection pin n p q d c q hff ptctsc a7Ca0 wdaten stopwait [5] [1] [2] [4] [3] [6] addren d7Cd0 rdaten e
motorola parallel input/output m68hc11 7-18 reference manual identical at port c regardless of the address written to. the second type cycle is a read from an external address. the last two cycle types are reads of internal addresses that is, reads of a memory location or register inside the MC68HC11a8. for debug- ging, the data read from the internal location is driven out of port c to be monitored with a logic analyzer. for normal use of the mcu, the data from the internal reads is not driven out of port c because it could conflict with some external device. there is an internal read visibility (irv) control bit in the MC68HC11a8 determining whether or not internal read data will be driven out of port c. the irv bit and the expansion bus are described in greater detail in 2.6 typical expanded-mode-system connec- tions . logic in the MC68HC11a8 generates the signals ptctsc, addren, wdaten, and rdaten to control the activity of port c, depending on the type bus cycle to be per- formed. the operation of these signals is explained in 7.3.4.1 port c pin logic for expanded modes . figure 7-12 summarizes the idealized timing of these signals for the four types of bus cycles. 7.3.4.3 port c single-chip mode pin logic refer to figure 7-13 for the following discussion. during a write to ddrc, data is clocked into hff [1] by the write ddrc (wddrc) signal. during a read of ddrc, transmission gate [2] is enabled by the read ddrc (rddrc) signal, which couples the output of the ddrc hff onto the internal data bus. during reset, hff [1] is forced to zero, which configures port c pins as high-impedance inputs. the state of ddrc at the output of hff [1] controls port c output buffer [3] via nor gate [4]. the state of ddrc also influences the source of data for reads of the portc register via nand gate [6]. the cwom control bit allows the user to disable the p-channel driver of output buffer [3]. cwom simultaneously affects all eight bits of port c. since the n-channel driver is not affected by cwom, cwom equal one causes port c to become an open-drain- type output port. when a port c bit is logic zero, it is actively driven low by the n-chan- nel driver. when a port c bit is logic one, it becomes high impedance since neither the n- nor p-channel devices are active. it is customary to have an external pull-up resistor on lines that are driven by open-drain devices. port c can only be configured for wired- or operation when the mcu is in a single-chip mode of operation.
m68hc11 parallel input/output motorola reference manual 7-19 figure 7-12 summary of idealized port c expanded-mode timing extal as e internal signals data to cpu data from cpu address, r/ w ph2 ph1 oscclk port c wdaten rdaten addren ptctsc read from internal address (irv=1) port c rdaten addren ptctsc read from internal address (irv=0) port c rdaten addren ptctsc read from external address port c wdaten addren ptctsc write to any address addr addr addr addr data next addr next addr data data valid valid must be valid
motorola parallel input/output m68hc11 7-20 reference manual figure 7-13 port c single-chip mode pin logic and gate [5] provides an override to ddrc during the three-state variation of full-out- put handshake. in this handshake mode, the hnds and oin control bits are ones, en- abling and gate [5]. while and gate [5] is enabled, a one from exclusive-or gate [7] will force output buffer [3] to be enabled, regardless of the state of the ddrc bit from hff [1]. the ega control bit specifies the level required at the stra pin to force port c pins to be outputs. cwom oin hnds pc7Cpc0 v dd protection pin n p d q hff rportc wddrc wportcl stopwait [14] [3] [2] [16] [13] rst d7Cd0 rportcl straedge q d c q hff [15] [6] [10] [8] d c q q hff d c q q hffr oin hnds ega wportc rddrc stra pin [7] [5] [4] [1] [12] [17] [11] [9] [18] [19] [20] qc r
m68hc11 parallel input/output motorola reference manual 7-21 while the output-handshake mode is specified, any of the port c bits having their cor- responding ddrc bits set to zero are configured for the three-state variation of full- output handshake. for those bits, the corresponding port c pins will appear as high- impedance inputs while the stra pin is at its selected inactive level. when the stra pin goes to its active level, and gate [5] will force all port c pins to the output mode. any port c bits having their corresponding ddrc bits set to one will be driven outputs, regardless of the logic at and gate [5]. while the mcu is operating in output-handshake mode, nand gate [14] outputs zero and nand gate [6] outputs one. when portc is read in this case, and gate [10] en- ables transmission gate [11] to couple the logic state from point [12] inside the output buffer onto the internal data bus. when a port c pin is configured for output by its cor- responding ddrc bit equal one at hff [1], inverter [15] outputs zero and nand gate [6] outputs one. again, when portc is read, and gate [10] enables transmission gate [11] to couple the logic state from point [12] inside the output buffer onto the in- ternal data bus. when neither of the previous conditions are true, the port c pin is con- figured for input and nand gate [6] outputs a zero. in this case, when portc is read, and gate [8] enables transmission gate [9] to couple the buffered state of the corre- sponding port c pin from the strobed buffers [13] onto the internal data bus. on writes to port c, data is clocked into the hff [16] by the output of or gate [17]. a write to either the portc register or the portcl register will enable hff [16] via or gate [17]. the output of hff [16] drives the port c pins through buffer [3] subject to the controls on the buffer described in the previous paragraphs. the port c latch register (portcl) is composed of hffs [18] and [19]. normally, the strobe a edge signal (straedge) is low so hff [19] is latched and hff [18] is trans- parent. when a selected edge is asynchronously detected at the strobe a pin, a short active-high pulse is issued on straedge. while straedge is high, hff [18] is temporarily latched so stable data is transferred into hff [19]. when the portcl reg- ister is read, the rportcl signal enables transmission gate [20] to couple the output of hff [19] onto the internal data bus. the stopwait signal is normally high, enabling strobe buffers [13]. when the mcu is in the stop or wait power-saving modes, stopwait is low, and strobe buffers [13] are disabled. this function was included to reduce power consumption mainly in the expanded modes where port c is a multiplexed address/data bus, but there is a side effect that can influence strobe and handshake input at port c in a very special case. the wait mode definition states that any enabled interrupt source can be used to force the mcu to return to normal operation. an active edge at the stra pin is a possible source of the interrupt that will wake the mcu from the wait standby mode. although the edge at stra will wake the mcu from the wait mode, valid data will not be latched into portcl because strobe input buffers [13] were disabled at the time of the asyn- chronous edge at stra. 7.3.4.4 port c idealized single-chip mode timing figure 7-14 shows the idealized timing for important port c control signals. because
motorola parallel input/output m68hc11 7-22 reference manual this timing diagram does not reflect any propagation delays, it cannot be used as a substitute for data-sheet timing specifications. this information is useful for under- standing the basis for data-sheet timing specifications so timing information can be ex- trapolated for bus frequencies other than that used for the data sheet. figure 7-14 idealized port c single-chip mode timing during a read of port c, the rportc signal enables transmission gates that drive port c data onto the internal data bus. after the rportc signal is negated, data is held stable on the self-latching internal data bus. the cpu actually requires data to be sta- ble for a setup time before and a hold time after the rising edge of the internal ph2 clock. the rportc signal is negated one-quarter cycle before this time so data will be stable while the cpu is actually reading it. during a ddrc read, the rddrc signal enables a transmission gate to couple the state of the ddrc bit to the internal data bus. in contrast to the rportc signal, rd- drc is active while the cpu is actually reading the data from the internal data bus, which does not pose potential problems because it is not possible for the ddrc value to change in the same cycle it is being read. the timing for the rportcl signal is the same as that for the rddrc signal. unlike port c output (single-chip mode) new port c data valid data required at cpu write to port c read from port c ph2 (internal) extal as rportc wportc or wportcl port c output pins e new port c data port c output pins (mc68hc24 only) rportcl or rddrc read portcl or ddrc wddrc write to ddrc port c input (single-chip mode)
m68hc11 parallel input/output motorola reference manual 7-23 ddrc data, data in the portcl register can change at any time since the strobe a latching edge is asynchronous. since it is undesirable for data to be changing at the instant the cpu is latching in this data, the user should avoid this synchronization haz- ard. usually, the system design automatically solves the problem because an edge on stra cannot normally occur during a read of portcl. for example, in a full-input handshake, portcl is only read in response to recognizing that the staf has been set. in such a case, the edge that caused staf to be set and data to be latched into portcl will have occurred several cycles before the portcl read could possibly occur. also, in the full-handshake protocol, the external device is inhibited from latch- ing new data into portcl until the previous data is read from portcl. this inhibit is accomplished by the strb handshake output. writes to port c at portc or portcl and writes to ddrc are controlled by wportc, wportcl, and wddrc, respectively. all three signals are synchronized to the falling edge of the internal ph2 clock, which corresponds to the center of the e high time. 7.3.4.5 special considerations for port c on mc68hc24 pru since the external pru does not have access to the internal ph2 clock of the MC68HC11a8, there are slight differences in the timing of port b, port c, stra, and strb activities. figure 7-14 shows the differences between internal MC68HC11a8 writes to port c and mc68hc24 writes to port c. 7.3.5 as (stra) pin in expanded modes, this pin acts as the as control signal, which is used to demultiplex low-order addresses from data at port c. in single-chip modes, this pin acts as the stra input, which serves the handshake i/o subsystem on the MC68HC11a8. the mc68hc24 can be used to regain the stra functions when the mcu is operating in an expanded mode. 7.3.5.1 as (stra) pin logic refer to figure 7-15 for the following discussion. when the MC68HC11a8 is operat- ing in a single-chip mode, the mda control bit is zero; thus, both the p- and n-channel output drivers are disabled. while the mcu is operating in an expanded mode, the mda control bit enables the output driver logic. as long as the mcu is not in stop mode, the as signal is buffered and driven out the as pin.
motorola parallel input/output m68hc11 7-24 reference manual figure 7-15 as (stra) pin logic when the MC68HC11a8 is in stop mode, the stop signal goes high, which forces the as pin to logic zero. a one on stop forces a zero on one input of nand gate [1], which forces a zero on one input of nand gate [2], which disables the p-channel driv- er. the one on stop also forces a one at the output of nand gate [3], which places a zero on the lower input of nor gate [4]. since the one on mda forces the other input of nor gate [4] to zero, the output of this nor gate will be one, which enables the n- channel driver and forces the pin to zero. hysteresis buffer [5] is described in 7.3.1.1 pa[2:0] (ic[3:1]) pin logic . ega controls the block of logic [7], which detects asynchronous edges on the signal from inverter [6], the buffered signal from the strobe a pin. the output from the block of logic [7] is a short high-going asynchronous pulse, which is used to asynchronously latch data from the port c pins into the portcl register. in response to the asynchronous pulse from block [7], the block of logic [8] produces a pulse that is synchronized to the internal ph2 clock. provided the asynchronous pulse meets a setup time before the rising edge of ph2, the output of block [8] will go synchronize to ph2 used to set staf flag and to terminate strb q [5] stop as mda [1] ega detect active edge on stra short asynchronous pulse used to trigger portcl latches [3] [6] [7] [8] as (stra) v dd protection pin n p [2] [4] q r s
m68hc11 parallel input/output motorola reference manual 7-25 high at that ph2 rising edge and stay high until ph2 goes low. if the setup time is not met, the pulse will appear at the next ph2, causing a delay from when an edge is pre- sented at the stra pin until it is recognized by the logic of block [8]. the delay could be from a few nanoseconds to a full e-clock cycle, depending on where the edge oc- curs relative to the clocks. the rising edge of the internal ph2 clock corresponds to the center of the e-clock low time. a significant number of internal logic-gate delays exists between the stra pin and the block of logic [8]. the synchronized pulse from block [8] is used for several functions in the handshake i/o subsystem. staf is set by this pulse. the arming mechanism for automatically clearing staf is cleared by this pulse. this pulse can terminate the strb output in some handshake modes. these functions and their timing are discussed in greater de- tail in 7.4 handshake i/o subsystem . 7.3.5.2 special considerations for stra on mc68hc24 pru because the external pru does not have access to the internal ph2 clock of the MC68HC11a8, slight differences exist in the timing of port b, port c, stra, and strb activities. the differences for strobe a are associated with the block of logic [8] in fig- ure 7-15 . although figure 7-15 depicts the MC68HC11a8, there is a similar block of logic in the mc68hc24. in the mc68hc24, as and e are used to synchronize the strobe a pulse to the e clock. any strobe a edge meeting a setup time to the falling edge of as results in a synchronized pulse that is high for the next e-clock high time. this pulse is used for the same purposes as the ph2 synchronized pulse in the MC68HC11a8. 7.3.6 port d port d is a six-bit bidirectional data port. two port d pins alternately serve as the re- ceive and transmit data pins for the on-chip asynchronous sci system. the other four port d pins alternately serve the on-chip synchronous spi system. although the pin logic for all six port d pins is essentially identical, each pin is described separately to note subtle differences. the following paragraphs explain the detailed logic associated with port d pins and the idealized timing of important port d control signals. 7.3.6.1 pd0 (rxd) pin logic refer to figure 7-16 for the following discussion. the data direction specification for this pin is held in hff [1]. during a write to the ddrd register, the wddrd signal is asserted, which causes data to be transferred into hff [1] from the internal data bus. a read of ddrd causes the rddrd signal to be asserted, which enables transmis- sion gate [2] to couple the output of hff [1] onto the internal data bus. during reset, hff [1] is cleared to zero, configuring this pin as a high-impedance input. the state of ddrd controls the pin output buffer via and gate [3], and ddrd affects the source of data for port d reads via transmission gates [4] and [5]. when the ddrd bit from hff [1] is zero, and gate [3] outputs a zero, which disables output driver [9]. when the ddrd bit from hff [1] is zero, transmission gate [5] is enabled. in this case, reads of port d enable transmission gate [6], coupling the buffered pin state from in- verters [7] to the internal data bus. when the ddrd bit from hff [1] is one, transmis-
motorola parallel input/output m68hc11 7-26 reference manual sion gate [4] is enabled. in this case, reads of port d enable transmission gate [6], coupling the level from the output of hff [8] to the internal data bus, which corre- sponds to the output level for the pin before output driver [9]. since output driver [9] can be configured for wired-or operation, some external source can force the pin low, even if the logic for this pin is trying to output a one. in this case, a read of port d will return the intended logic one from inside the output buffer rather than the zero from the pin. figure 7-16 pd0 (rxd) pin logic during a write to port d, the wportd signal is asserted, causing data from the inter- nal data bus to be latched into hff [8]. written data is then buffered to the pin by out- put driver [9] subject to data direction control from and gate [3] and wired-or control from the dwom control bit. when the dwom control bit is one, the p-channel driver is disabled so port d outputs act as open-drain drivers. the dwom control bit simul- taneously affects all port d pins. when the output of and gate [3] is zero, the output driver is completely disabled; thus, this pin is configured as a high-impedance input. and gate [3] will output a zero to dis- able the output driver whenever the corresponding ddrd bit is zero from hff [1]. hff d c q r pd0 (rxd) v dd protection pin n p [9] [1] dwom hffr d c q to sci receiver rddrd rcvon wportd d0 rst wddrd rportd [2] [4] [5] [7] [6] [3] [8] q q
m68hc11 parallel input/output motorola reference manual 7-27 and gate [3] will also disable the output driver when the sci receiver is enabled by the receiver-on signal (rcvon). the state of the ddrd bit still influences the source of read data when the rcvon signal is forcing the pin to a high-impedance state. this pin alternately serves as the receive data (rxd) input pin for the asynchronous sci system. the sci receiver is enabled by the receive enable (re) control bit in an sci control register, which forces the rcvon signal to one, disabling pin output driver [9], regardless of the state of the ddrd bit from hff [1]. the state of the ddrd bit allows the programmer to read the rxd pin (ddrd = 0) or the value in port d latch [8] (when ddrd = 1). data from the pin is buffered by inverters [7] and driven to the sci receive logic. the data path from the pin to the sci receive logic is not affected by the state of ddrd. 7.3.6.2 pd1 (txd) pin logic refer to figure 7-17 for the following discussion. the data direction specification for this pin is held in hff [1]. during a write to the ddrd register, the wddrd signal is asserted, causing data to be transferred into hff [1] from the internal data bus. a read of ddrd causes the rddrd signal to be asserted, which enables transmission gate [2] to couple the output of hff [1] onto the internal data bus. during reset, hff [1] is cleared to zero, which configures this pin as a high-impedance input. the state of ddrd controls the pin output buffer via or gate [3], and ddrd affects the source of data for port d reads via transmission gates [4] and [5]. when the ddrd bit from hff [1] is one, or gate [3] outputs a one, which enables output driver [9]. al- so, when the ddrd bit from hff [1] is one, transmission gate [4] is enabled. in this case, reads of port d enable transmission gate [6], which couples the level from the output of hff [8] to the internal data bus. the value returned on such a read corre- sponds to the last value written to the corresponding bit of port d. since output driver [9] can be configured for wired-or operation, some external source can force the pin low even if the pin logic for this pin is attempting to output a one. if the ddrd bit did not affect the source of the read data, an erroneous zero could be read when the pin logic is actually trying to output a one. when the ddrd bit from hff [1] is zero, or gate [3] outputs a zero, which disables output driver [9]. also, when the ddrd bit is zero, transmission gate [5] is enabled. in this case, reads of port d enable transmis- sion gate [6], which couples the buffered pin state from inverters [7] to the internal data bus.
motorola parallel input/output m68hc11 7-28 reference manual figure 7-17 pd1 (txd) pin logic during a write to port d, the wportd signal is asserted, causing data from the inter- nal data bus to be latched into hff [8]. when the sci transmitter is enabled, the trans- mit-on (xmiton) signal is one and transmission gate [10] is enabled, which couples serial transmit data (xmitdata) to pin driver [9]. when the sci transmitter is disabled, the xmiton signal is zero, and transmission gate [11] is enabled, which couples port d data from hff [8] to pin driver [9]. pin output driver [9] is enabled by data direction logic from or gate [3]. the dwom control bit can optionally disable the p-channel driver of output buffer [9]. when the dwom control bit is one, the p-channel driver is disabled, causing port d outputs to act as open-drain drivers. the dwom control bit concurrently affects all port d pins. when the output of or gate [3] is zero, the output driver is completely disabled; thus, this pin is configured as a high-impedance input. or gate [3] will output a zero to disable the output driver whenever the corresponding ddrd bit is zero from hff [1] and the sci transmitter is disabled by the xmiton signal. the state of the ddrd bit still influences the source of read data when the xmiton signal is forcing the pin to the output configuration. hff d c q r pd1 (txd) v dd protection pin n p [9] [1] dwom hffr d c q rddrd wportd d1 rst wddrd rportd [2] [4] [5] [7] [6] [3] [8] xmiton xmitdata [10] [11] q q
m68hc11 parallel input/output motorola reference manual 7-29 this pin alternately serves as the transmit data (txd) output pin for the asynchronous sci system. the sci transmitter is enabled by the te control bit in an sci control reg- ister. enabling the transmitter forces the pin driver to be configured as an output by forcing a one at the output of or gate [3]. the state of the ddrd bit allows the pro- grammer to read the txd pin (ddrd = 0) or the value in port d latch [8] (when ddrd equals one). the sci transmitter retains control of the port d pin by keeping xmiton equal to one as long as any information is being transmitted (even after the te bit is written to zero). this control assures that a transmission will not be cut off in the middle of a serial character. the user can control what happens to the txd pin when the transmitter is finished. when the transmitter is finished using the txd pin, the xmiton signal switches from one to zero, which causes the data direction to be controlled by the ddrd bit from hff [1] instead of the xmiton input to or gate [3]. disabling xmiton also causes transmission gate [10] to be disabled and transmission gate [11] to be enabled. if the corresponding ddrd bit is zero, the pin will revert to being a high-impedance input when the transmitter is finished. if the ddrd bit is one and the last data written to the corresponding bit of port d was a zero, the pin will revert to a driven logic zero when the transmitter is finished. if the ddrd bit is one and the last data written to the corre- sponding bit of port d was a one, the pin will revert to a driven logic one when the trans- mitter is finished. 7.3.6.3 pd2 (miso) pin logic this pin alternately functions as the miso pin when the synchronous spi system is enabled. refer to figure 7-18 for the following discussion. the data direction specifi- cation for this pin is held in hff [1], during a write to the ddrd register, the wddrd signal is asserted, which causes data to be transferred into hff [1] from the internal data bus. a read of ddrd causes the rddrd signal to be asserted, enabling trans- mission gate [2] to couple the output of hff [1] onto the internal data bus. when hff [1] is cleared to zero, this pin is configured as a high-impedance input. or gate [13] causes hff [1] to be cleared to zero during reset. or gate [13] also causes hff [1] to be cleared if an spi mode fault (mfault) occurs. an spi mode fault is caused when a device configured as a master spi device is selected as if it were a slave. this condition could indicate that more than one spi device is attempting to drive the common spi lines, which could cause a bus conflict. to avoid the possibility of latchup, the port d pins associated with the spi are immediately forced to their input configuration. the actual data direction for this port d pin is determined by the logic output of nand gate [3]. when the spi system is disabled, the ddrd bit from hff [1] controls direc- tion. when the spi system is enabled in master mode, this pin is forced to a high-im- pedance input. when the spi system is enabled in slave mode, the ddrd bit from hff [1] controls direction. this last condition means that the user must set the corre- sponding ddrd bit to one to enable slave data output from this pin when the spi sys- tem is enabled for slave operation. the uses and implications of this logic are discussed in greater detail in section 8 synchronous serial peripheral interface .
motorola parallel input/output m68hc11 7-30 reference manual figure 7-18 pd2 (miso) pin logic when the output of nand gate [3] is one, driver [9] is disabled so the pin is configured as a high-impedance input. to enable pin driver [9], both inputs to nand gate [3] must be ones. when the spi system is disabled, spe is zero, which makes the output of nand gate [12] a one. a logic one enables nand gate [3] so that the ddrd bit from hff [1] can enable or disable driver [9]. when the spi system is operating as a mas- ter, spe will be one and slave on (slavon) will be zero. this configuration causes nand gate [12] to output a zero, which disables output driver [9], regardless of the state of the ddrd bit at hff [1]. when the spi system is enabled as a slave, spe is one and slavon is one. this configuration causes nand gate [12] to output a one, which enables nand gate [3] to control the direction of output buffer [9] based on the state of the ddrd bit from hff [1]. output driver [9] can be placed in a wired-or configuration by the dwom control bit. this control bit simultaneously affects all six port d pins. when dwom is one, the p- hff d c q r pd2 (miso) v dd protection pin n p [9] [1] dwom hffr d c q rddrd wportd d2 mfault wddrd rportd [2] [4] [5] [7] [6] [3] [8] [10] [11] slavdo spe rst slavon [12] [13] to spi master data in q q
m68hc11 parallel input/output motorola reference manual 7-31 channel device in the output driver is disabled so the pin cannot be actively driven high. when the pin attempts to output a logic one, the n-channel device is disabled; thus, the pin appears as a high-impedance input. an external pull-up is used to pas- sively pull the pin high. the data for output driver [9] comes from transmission gate [10] or [11]. when the spi system is enabled, the spe bit is one; thus, transmission gate [10] is enabled, and data for the output driver comes from the spi slave data output signal (slavdo). when the spi system is disabled, the spe control bit is zero; thus, transmission gate [10] is disabled and transmission gate [11] is enabled. in this case, port d data is cou- pled from the output of hff [8] to the input of output driver [9]. during a write to port d, the wportd signal is asserted, which causes data to be latched into hff [8] from the internal data bus. during a read of port d, transmission gate [6] is enabled by the rportd signal to cou- ple data to the internal data bus. the source of data for port d reads depends on the direction control for the output driver. if the output of nand gate [3] is zero, output driv- er [9] is enabled and transmission gate [4] is enabled. in this case, port d reads return the data from a point inside the output driver. if the output of nand gate [3] is one, transmission gate [5] is enabled. in this case, reads of port d return the buffered state from the pin through inverters [7]. the output of inverters [7] drives the serial master data input to the spi system logic. the source of this data is always from the miso pin and is not affected by the data direction logic. 7.3.6.4 pd3 (mosi) pin logic this pin alternately functions as the mosi pin when the synchronous spi system is enabled. refer to figure 7-19 for the following discussion. the data direction specifi- cation for this pin is held in hff [1]. during a write to the ddrd register, the wddrd signal is asserted, causing data to be transferred into hff [1] from the internal data bus. a read of ddrd causes the rddrd signal to be asserted, which enables trans- mission gate [2] to couple the output of hff [1] onto the internal data bus. when hff [1] is cleared to zero, this pin is configured as a high-impedance input. or gate [13] causes hff [1] to be cleared to zero during reset. or gate [13] also causes hff [1] to be cleared if an spi mode fault occurs. an spi mode fault is caused when a device configured as a master spi is selected as if it were a slave. this condition could indicate that more than one spi device is attempting to drive the common spi lines, which could cause a bus conflict. to avoid the possibility of latchup, the port d pins associated with the spi are immediately forced to their input configuration. the actual data direction for this port d pin is determined by the logic output of nand gate [3]. when the spi system is disabled, the ddrd bit from hff [1] controls direc- tion. when the spi system is enabled in slave mode, this pin is configured as a high- impedance input. when the spi system is enabled in master mode, the ddrd bit from hff [1] controls direction. this last condition means that the user must set the corre- sponding ddrd bit to one to enable master data output from this pin when the spi
motorola parallel input/output m68hc11 7-32 reference manual system is configured for master operation. the uses and implications of this logic are discussed in greater detail in section 8 synchronous serial peripheral interface . figure 7-19 pd3 (mosi) pin logic when the output of nand gate [3] is one, driver [9] is disabled; thus, the pin is config- ured as a high-impedance input. to enable pin driver [9], both inputs to nand gate [3] must be ones. when the spi system is disabled, spe is zero, making the output of nand gate [12] a one. this configuration enables nand gate [3] so that the ddrd bit from hff [1] can enable or disable driver [9]. when the spi system is enabled as a slave, spe is one and master on (mstron) is zero. this configuration causes nand gate [12] to output zero, which disables output driver [9], regardless of the state of the ddrd bit at hff [1]. when the spi system is enabled as a master, spe is one and mstron is one. this configuration causes nand gate [12] to output a one, which enables nand gate [3] to control the direction of output buffer [9] based on the state hff d c q r pd3 (mosi) v dd protection pin n p [9] [1] dwom hffr d c q rddrd wportd d3 mfault wddrd rportd [2] [4] [5] [7] [6] [3] [8] [10] [11] mstrdo spe rst mstron [12] [13] to spi slave data in q q
m68hc11 parallel input/output motorola reference manual 7-33 of the ddrd bit from hff [1]. output driver [9] can be placed in a wired-or configuration by the dwom control bit. this control bit simultaneously affects all six port d pins. when dwom is one, the p- channel device in the output driver is disabled so the pin cannot be actively driven high. when the pin attempts to output logic one, the n-channel device is disabled; thus, the pin appears as high-impedance input. an external pull-up is used to passively pull the pin high. the data for output driver [9] comes from transmission gate [10] or [11]. when the spi system is enabled, the spe bit is one; transmission gate [10] is enabled, and data for the output driver comes from the spi master data output signal (mstrdo). when the spi system is disabled, the spe control bit is zero; transmission gate [10] is disabled and transmission gate [11] is enabled. in this case, port d data is coupled from the out- put of hff [8] to the input of output driver [9]. during a write to port d, the wportd signal is asserted, which causes data to be latched into hff [8] from the internal data bus. during a read of port d, transmission gate [6] is enabled by the rportd signal to cou- ple data to the internal data bus. the source of data for port d reads depends on the direction control for the output driver. if the output of nand gate [3] is zero, output driv- er [9] is enabled and transmission gate [4] is enabled. in this case, port d reads return the data from a point inside the output driver. if the output of nand gate [3] is one, transmission gate [5] is enabled. in this case, reads of port d return the buffered state from the pin through inverters [7]. the output of inverters [7] drives the serial slave data input to the spi system logic. because the source of this data is always from the mosi pin, it is not affected by the data direction logic. 7.3.6.5 pd4 (sck) pin logic this pin alternately functions as the spi sck output pin when the synchronous spi system is enabled. refer to figure 7-20 for the following discussion. the data direc- tion specification for this pin is held in hff [1]. during a write to the ddrd register, the wddrd signal is asserted, causing data to be transferred into hff [1] from the internal data bus. a read of ddrd causes the rddrd signal to be asserted, which enables transmission gate [2] to couple the output of hff [1] onto the internal data bus. when hff [1] is cleared to zero, this pin is configured as a high-impedance input. or gate [13] causes hff [1] to be cleared to zero during reset. or gate [13] also causes hff [1] to be cleared if there is an spi mode fault. an spi mode fault is caused when a device configured as a master spi device is selected as if it were a slave. this con- dition could indicate that more than one spi device is attempting to drive the common spi lines, which could cause a bus conflict. to avoid the possibility of latchup, the port d pins associated with the spi are immediately forced to their input configuration. the actual data direction for this port d pin is determined by the logic output of nand gate [3]. when the spi system is disabled, the ddrd bit from hff [1] controls direc-
motorola parallel input/output m68hc11 7-34 reference manual tion. when the spi system is enabled in slave mode, this pin is forced to a high-im- pedance input. when the spi system is enabled in master mode, the ddrd bit from hff [1] controls direction. this last condition means that the user must set the corre- sponding ddrd bit to one to enable the master clock output from this pin when the spi system is configured for master operation. the uses and implications of this logic are discussed in greater detail in section 8 synchronous serial peripher- al interface . figure 7-20 pd4 (sck) pin logic when the output of nand gate [3] is one, driver [9] is disabled so the pin is configured as a high-impedance input. to enable pin driver [9], both inputs to nand gate [3] must be ones. when the spi system is disabled, spe is zero, which makes the output of nand gate [12] a one. this enables nand gate [3] so that the ddrd bit from hff [1] can enable or disable driver [9]. when the spi system is enabled as a slave, spe is hff d c q r pd4 (sck) v dd protection pin n p [9] [1] dwom hffr d c q rddrd wportd d4 mfault wddrd rportd [2] [4] [5] [7] [6] [3] [8] [10] [11] spisck spe rst mstron [12] [13] to spi slave clock q q
m68hc11 parallel input/output motorola reference manual 7-35 one and mstron is zero. this configuration causes nand gate [12] to output a zero, which disables output driver [9], regardless of the state of the ddrd bit at hff [1]. when the spi system is enabled as a master, spe is one and mstron is one. this configuration causes nand gate [12] to output a one, which enables nand gate [3] to control the direction of output buffer [9] based on the state of the ddrd bit from hff [1]. output driver [9] can be placed in a wired-or configuration by the dwom control bit. this control bit simultaneously affects all six port d pins. when dwom is one, the p- channel device in the output driver is disabled so the pin cannot be actively driven high. when the pin attempts to output a logic one, the n-channel device is off; thus, the pin appears as a high-impedance input. an external pull-up is used to passively pull the pin high. the data for output driver [9] comes from transmission gate [10] or [11]. when the spi system is enabled, the spe bit is one; thus, transmission gate [10] is enabled, and data for the output driver comes from the spi master clock output signal (spisck). when the spi system is disabled, the spe control bit is zero; transmission gate [10] is disabled and transmission gate [11] is enabled. in this case, port d data is coupled from the output of hff [8] to the input of output driver [9]. during a write to port d, the wportd signal is asserted, which causes data to be latched into hff [8] from the internal data bus. during a read of port d, transmission gate [6] is enabled by the rportd signal to cou- ple data to the internal data bus. the source of data for port d reads depends on the direction control for the output driver. if the output of nand gate [3] is zero, output driv- er [9] is enabled and transmission gate [4] is enabled. in this case, port d reads return the data from a point inside the output driver. if the output of nand gate [3] is one, transmission gate [5] is enabled. in this case, reads of port d return the buffered state from the pin through inverters [7]. the output of inverters [7] drives the spi slave clock input to the spi system logic. be- cause the source of this clock is always from the sck pin, it is not affected by the data direction logic. when the spi system is operating in master mode, the spi clock is generated by the spi system logic, and the slave clock input from inverters [7] is ig- nored. 7.3.6.6 pd5 ( ss) pin logic this pin alternately functions as the ( ss) pin when the synchronous spi system is en- abled. refer to figure 7-21 for the following discussion. the data direction specifica- tion for this pin is held in hff [1]. during a write to the ddrd register, the wddrd signal is asserted, causing data to be transferred into hff [1] from the internal data bus. a read of ddrd causes the rddrd signal to be asserted, which enables trans- mission gate [2] to couple the output of hff [1] onto the internal data bus. when hff [1] is cleared to zero during reset, this pin is configured as a high-impedance input. un- like the other three pins associated with the spi system, the direction of this pin is not affected by mode faults.
motorola parallel input/output m68hc11 7-36 reference manual figure 7-21 pd5 ( ss) pin logic the actual data direction for this port d pin is determined by the logic output of nand gate [3]. when the spi system is disabled, the ddrd bit from hff [1] controls direc- tion. when the spi system is enabled in slave mode, this pin is configured as a high- impedance input. when the spi system is enabled in master mode, the ddrd bit from hff [1] controls direction. this last condition allows a user to decide how this pin will be used when the spi system is configured for master mode. if the ddrd bit is cleared to zero, this ss pin is used as an input to detect mode faults. if the spi system is con- figured so that mode faults would not occur, as in a single-master system, the user can set the ddrd bit corresponding to the ss pin. in this case, the pin becomes a general- purpose output pin not associated with the spi system. the uses and implications of this logic are discussed in greater detail in section 8 synchronous serial pe- ripheral interface . when the output of nand gate [3] is one, driver [9] is disabled; thus, the pin is config- ured as a high-impedance input. to enable pin driver [9], both inputs to nand gate [3] must be ones. when the spi system is disabled, spe is zero, making the output of nand gate [10] a one. this configuration enables nand gate [3] so that the ddrd hff d c q r pd5 v dd protection pin n p [9] [1] dwom hffr d c q rddrd wportd d5 wddrd rportd [2] [4] [5] [7] [6] [3] [8] spe rst [10] slave enable to spi spe [11] mstr q q [12]
m68hc11 parallel input/output motorola reference manual 7-37 bit from hff [1] can enable or disable driver [9]. when the spi system is enabled as a slave, spe is one, and the master/slave control bit (mstr) is zero. this configura- tion causes nand gate [10] to output zero, which disables output driver [9], regardless of the state of the ddrd bit at hff [1]. when the spi system is enabled as a master, spe is one and mstr is one. this causes nand gate [10] to output one, which en- ables nand gate [3] to control the direction of output buffer [9] based on the state of the ddrd bit from hff [1]. output driver [9] can be placed in a wired-or configuration by the dwom control bit. this control bit simultaneously affects all six port d pins. when dwom is one, the p- channel device in the output driver is disabled so the pin cannot be actively driven high. when the pin attempts to output logic one, the n-channel device is disabled; thus, the pin appears as a high-impedance input. an external pull-up is used to pas- sively pull the pin high. the data for output driver [9] comes from the output of hff [8]. during a write to port d, the wportd signal is asserted, which causes data to be latched into hff [8] from the internal data bus. during a read of port d, transmission gate [6] is enabled by the rportd signal to cou- ple data to the internal data bus. the source of data for port d reads depends on the direction control for the output driver. if the output of nand gate [3] is zero, output driv- er [9] is enabled and transmission gate [4] is enabled. in this case, port d reads return the data from a point inside the output driver. if the output of nand gate [3] is one, transmission gate [5] is enabled. in this case, reads of port d return the buffered state from the pin through inverters [7]. the slave enable signal to the spi logic is developed by nor gate [11]. the active- low ss signal from the pin is buffered by inverters [7] and drives one input of nor gate [11]. the other two inputs to this nor gate act as enables, and the output of the nor gate is an active-high slave select signal to the main spi logic. when the spi system is disabled, spe is zero, disabling nor gate [11] by forcing its output to zero. when pin output driver [9] is enabled by a zero at the output of nand gate [3], nor gate [11] is also disabled by the output of inverter [12]. this disabled condition corresponds to spi being enabled as a master and the ddrd bit associated with the ss pin being set to one. in this case, the pd5 pin is being used as a general-purpose output and has nothing to do with the spi system. to avoid an erroneous mode fault condition due to a zero at this pin, the ss signal is disabled to the spi logic. 7.3.6.7 idealized port d timing figure 7-22 shows the idealized timing for important port d control signals. since this timing diagram does not consider any propagation delays, it cannot be used as a sub- stitute for data-sheet timing specifications. this information is useful for understanding the basis for data-sheet timing specifications so timing information can be extrapolated for bus frequencies other than that used for the data sheet. timing information con- cerning the spi system is included in section 8 synchronous serial pe- ripheral interface .
motorola parallel input/output m68hc11 7-38 reference manual figure 7-22 idealized port d timing on a port d read, the rportd signal enables transmission gates that drive port d data onto the internal data bus. after the rportd signal is negated, data is held sta- ble on the self-latching internal data bus. the cpu actually requires this data to be val- id for a setup before and hold time after the rising edge of the internal ph2 clock. port d writes cause changes to the port d output pins at the falling edge of the internal ph2 clock. this edge corresponds to the center of the e-clock high time. during a ddrd read, the rddrd signal enables a transmission gate to couple the state of the ddrd bit to the internal data bus. in contrast to the rportd signal, rd- drd is active while the cpu is actually reading the data from the internal data bus. although it should pose no problems to the user, there is a remote chance that the state of the ddrd bits associated with three of the spi pins (miso, mosi, and sck) could change asynchronously with respect to a ddrd read due to a mode fault. in such a case, the bits in transition could be read incorrectly. the timing for writes to ddrd is such that the pin configuration will change at the fall- ing edge of the internal ph2 clock. this edge corresponds to the middle of the e-clock high time. new port d data valid data required at cpu write to port d read from port d ph2 (internal) extal as port d input rportd port d output wportd port d output pins e rddrd read ddrd wddrd write to ddrd
m68hc11 parallel input/output motorola reference manual 7-39 7.3.7 port e the eight port e pins are fixed-direction input pins that also serve as a/d analog chan- nel inputs. each of the port e pins has this same logic. the following paragraphs de- scribe the detailed port e pin logic and the idealized timing of important port e signals. 7.3.7.1 port e pin logic figure 7-23 shows the detailed pin logic for one port e pin. when the internal a/d con- verter system samples a port e pin, n-channel device [1] is enabled to couple the an- alog level from the port e pin to the sample and hold capacitance in the a/d system. the enable signal to device [1] is active for the first 12 e-clock cycles of a conversion cycle for the associated analog channel. a more detailed discussion of the timing of this enable signal is included in section 12 analog-to-digital converter system . n-channel device [1] and the gate signal driving it are specially designed to accurately pass analog levels over the full v refl to v refh range, even if v refh is slightly above v dd . n- and p-channel devices [2] form an inverter whose input is connected to the pin and whose output is connected to the similar inverter stage [3]. unlike a usual cmos in- verter, the n-channel device is connected through another series n-channel device to v ss . this extra device acts as a strobe enable for the inverter. since the port e pins are also used as analog inputs, there will be times when the pin is at an intermediate level. intermediate levels cause normal cmos inverters to draw excessive power-sup- ply currents because both the n- and the p-channel devices can be partially turned on simultaneously, creating a low-impedance path between v dd and v ss . for port e pins, this path is interrupted by extra n-channel device [4].
motorola parallel input/output m68hc11 7-40 reference manual figure 7-23 port e pin logic four n-channel devices [4] and [5] are used to isolate the potential analog levels at the port e pins from the digital logic associated with port e. when port e is read digi- tally, the rporte signal is asserted to enable these devices. the devices [4] enable inverters [2] and [3]. the devices [5] connect the outputs of inverters [2] and [3] to the set and reset inputs of cross-coupled nand latch [7]. the rporte signal is only as- serted for one-fourth of an e-clock cycle for the cycle where port e is read. the cross- coupled nand latch holds this port e data until later in the read cycle when the cpu actually reads the data. the a/d read signal (atdread) is asserted during port e reads to enable transmission gate [8] to couple the data from output latch [7] to the internal data bus. digital reads of port e are not recommended during the sample portion of an a/d con- version cycle when the gate signal to n-channel device [1] is enabled. the concern is that enabling inverters [2] and [3] might disturb the analog sample that is occurring. this disturbance is caused by very tiny gate-to-source and gate-to-drain capacitances in n- and p-channel devices [2]. 7.3.7.2 idealized port e timing figure 7-24 shows the idealized timing for important port e control signals. this timing diagram, which does not consider any propagation delays, cannot be used as a sub- stitute for data-sheet timing specifications. this information is useful for understanding pe7Cpe0 v dd protection pin rporte v dd v dd d7Cd0 atdread sample 8C sample 1 to capacitive dac [1] [2] [3] [4] [5] [6] [7] [8]
m68hc11 parallel input/output motorola reference manual 7-41 the basis for data-sheet timing specifications so timing information can be extrapolated for bus frequencies other than that used for the data sheet. on a port e read, the rporte signal is asserted for one-fourth e-clock cycle to en- able the pin input buffers and transfer the digital value from the port e pins into cross- coupled nand latches in the pin logic for each port e pin. the atdread signal is also asserted to enable transmission gates that couple the outputs of the nand latches to the internal data bus. since the cpu does not actually use the data from the nand latches until after the rporte signal is disabled, the latches are actually acting as synchronizers for port e data. figure 7-24 idealized port e timing 7.4 handshake i/o subsystem the handshake i/o subsystem involves ports b and c, stra input, strb output, and the pioc register. the following paragraphs explains the strobe and handshake pro- tocols and the detailed operation of the pioc register. there are three primary modes of operation for the handshake i/o subsystem. the first (default) mode of operation is the simple strobe mode, which uses port b as a sim- ple strobe output port and port c as a simple latching input port. the second mode of operation is a full-input handshake; the third mode is a full-output handshake. in the full-handshake modes of operation, port b is not involved; therefore, it defaults to be- ing a general-purpose output port. if the application does not require handshake functions, these functions can generally be ignored. ports b and c can be used for simple general-purpose i/o; in fact, the stra and strb pins can even be used for limited non-handshake functions. when handshake functions are being used, it is usually possible to use any port c pins which are not needed for handshake as general-purpose i/o pins, without interfering with the handshake functions of the other port c pins. the one exception to this possibility is that while full-output handshake is specified, port c pins cannot usually function as general-purpose input pins. examples of mixed use of port c pins is presented in 7.4.5 valid data required at cpu read from port e ph2 (internal) extal as port e input rporte atdread e
motorola parallel input/output m68hc11 7-42 reference manual non-handshake uses of stra and strb pins . 7.4.1 simple strobe mode the simple strobe mode for the handshake i/o subsystem is selected by hnds equal to zero in the pioc register. at reset, hnds is forced to zero, which is the default mode of operation for the handshake i/o subsystem. in this mode, the oin and pls control bits in pioc have no meaning or effect. in simple strobe mode, port b is used as a strobe output port in conjunction with the strb output pin. port c is simultaneously used as a latching input port in conjunction with the stra input pin. the strobe output function at port b is independent of the latching input function at port c. figure 7-25 shows the idealized timing for simple strobe mode operations in the MC68HC11a8. the timing for the mc68hc24 is slightly different because the mc68hc24 does not have access to the internal ph2 clock of the MC68HC11a8. de- tailed descriptions of the strobe a and strobe b pins are presented in 7.3.3.2 special considerations for strb on mc68hc24 pru and 7.3.5.2 special considerations for stra on mc68hc24 pru . 7.4.1.1 port b strobe output. in response to a write to portb, data is changed at port b, and then a two e-cycle pulse is generated at the strb pin. although the invb control bit in pioc allows a choice of polarity for strobe b pulses, figure 7-25 only shows the invb equals one case, which selects active-high strobe b pulses. figure 7-25 idealized timing for simple strobe operations strobed output latched input staf port c strobe a strobe b port b e ph2 (internal) write port b new port b data
m68hc11 parallel input/output motorola reference manual 7-43 7.4.1.2 port c simple latching input data at port c is required to be valid for a short setup time before and a short hold time after the selected edge on the strobe a pin. since the edge on strobe a is asynchro- nous, it need not have any special relationship with the e clock. the internal staf bit, which indicates that port c data has been latched, must be synchronized with the in- ternal clocks to avoid setting the flag in the portion of a cycle where it could be read. this factor implies there may be a delay between when the actual port c data is latched and when the mcu becomes aware of it. not counting internal propagation de- lays, the MC68HC11a8 would have a delay between zero nanoseconds and one e- clock period. if the relationship between the strobe a edges and the e clock is known, the user can predict the delay between port c data latching and setting staf by a careful study of the strobe a pin description. 7.4.2 full-input handshake mode full-input handshake mode is selected when hnds is one and oin is zero. in this mode, the strobe b output acts as a ready signal to an external system. the external system should not attempt to strobe data into port c until the strobe b signal has been asserted, indicating a ready condition. the strobe a input is an edge-sensitive latch command, allowing the external system to asynchronously latch information into port c. when a ready condition is recognized, the external device places data on the port d inputs, then pulses the strobe a input. the active edge on strobe a latches data into the portcl register, sets staf (optionally causing an interrupt), and negates strobe b. negation of strobe b automatically inhibits the external system from strobing any new data into port c. reading the latched data from portcl (independent of clearing staf) causes strobe b to be asserted, indicating new data may now be strobed into port c. control bits allow flexibility to adapt to the requirements of a particular application. the invb control bit selects the polarity of the strobe b signals. the ega determines whether rising or failing edges will be the active edges for the strobe a input. the pls bit determines whether strobe b will operate in pulsed mode or interlocked mode. in the interlocked mode, strobe b is asserted when the portcl register is read and is negated when an active edge is detected at the strobe a input. in the pulsed mode, strobe b is asserted when the portcl register is read but only remains asserted for two e-clock cycles. figure 7-26 illustrates the full-input handshake protocol. separate wave forms are in- cluded to clarify the pulsed versus interlocked modes of strobe b. although the polarity of strobe b and the active edge for strobe a can be selected, the figure only shows the case where invb and ega are ones. this configuration specifies strobe a to be sen- sitive to rising edges and the active level on strobe b to be high. the timing shown in figure 7-26 is the idealized timing for the MC68HC11a8. the idealized timing for the mc68hc24 port replacement unit has small differences, which do not concern most users.
motorola parallel input/output m68hc11 7-44 reference manual figure 7-26 idealized timing for full-input handshake 7.4.3 full-output handshake mode full-output handshake mode is selected when hnds and oin are ones. in this mode, port c is used to output data to some external system. the strobe b output signal in- dicates that port c data is ready for the external system. the strobe a input is pulsed by the external system to acknowledge that it has accepted the data on port c. in the three-state variation of output handshake, strobe a also acts like the output enable of a 74hc244 buffer. figure 7-27 illustrates the full-output handshake protocol. this figure shows strobe b waveforms for both interlocked and pulsed modes. waveforms are also provided to show the three-state variation of the output-handshake protocol. although the polari- ties for strobes a and b are software programmable, only the case in which ega and invb are ones is shown. this case specifies strobe b is active high, strobe a responds to rising edges, and the active level on strobe a is low for the three-state variation of output handshake. read portcl (after reading pioc with staf=1) staf (pulsed) (interlocked) strobe b port c strobe a e ph2 (internal)
m68hc11 parallel input/output motorola reference manual 7-45 figure 7-27 idealized timing for full-output handshake 7.4.3.1 normal output handshake in an output-handshake transaction, data is output to port c pins by writing to the portcl register, which automatically causes strobe b to be asserted. the external system recognizes this strobe b signal as a ready indication. after accepting the data from port c, the external system pulses the strobe a input to acknowledge the receipt of data. the active edge on strobe a causes strobe b to be negated and staf to be set. staf signals that the mcu can begin the next transaction by writing the next byte of data to portcl. 7.4.3.2 three-state variation of output handshake the three-state variation of output handshake can be thought of as if a 74hc244 buffer had been placed in series with the port c outputs with its output enable connected to the strobe a signal. the transaction sequence is identical to the normal output hand- shake protocol previously described. port c pins, which are to act as three-state outputs, have their corresponding ddrc control bits cleared to zero. as long as the strobe a input is at its inactive level, all port c pins obey their corresponding ddrc specification. when strobe a goes to its active level, all port c pins act as driven outputs, regardless of their corresponding ddrc specification. the active level is automatically specified when ega is selected. if ega is zero, failing edges are selected and the active level is high. if ega is one, rising edg- es are selected and the active level is low. the relationship between the active edge and the active level at strobe a was chosen so that the active edge will correspond to the trailing edge of a port c output enable pulse to strobe a. e ph2 (internal) (pulsed) (interlocked) strobe b (ddr bits = 0) (ddr bits = 1) port c strobe a staf write portcl new port c data driven
motorola parallel input/output m68hc11 7-46 reference manual 7.4.4 parallel i/o control register (pioc) the pioc register is used to configure and control the handshake i/o subsystem in the MC68HC11a8. the following register and paragraphs describe each of the control or status bits in greater detail. staf strobe a flag this status flag is a key element of the handshake i/o subsystem. independent of the strobe or handshake mode, staf is always set as a result of a selected active edge at the stra pin. the edge at stra, which is asynchronous to the mcu e-clock, caus- es data to be asynchronously latched into the portcl register. the staf bit is syn- chronized to the internal ph2 clock. provided the asynchronous edge occurs at least a setup time before the rising edge of ph2, staf will become set at that ph2 rising edge. if this setup time is not met, then staf would not be set until the next ph2. the rising edge of ph2 corresponds to the center of the e-clock low time. the active edge at stra is software selectable by the ega bit in the pioc register. the staf bit is cleared by a two-step, automatic clearing sequence. the first step arms the clearing mechanism; the second step clears staf to zero. to arm the clear- ing mechanism, software reads the pioc register while the staf bit is set to one. the second step depends upon the strobe or handshake mode in effect. in simple strobe mode (hnds = 0), the second step of the clearing sequence is to read the portcl register. in full-input handshake mode (hnd s = 1 and oin = 0), the second step of the clearing sequence is to read the portcl register. in full-output handshake mode (hnds = 1 and oin = 1), the second step of the clearing sequence is to write to the portcl register. the handshake mode can be changed between the arming and clearing steps of this sequence. if the mode is changed, the action required for the sec- ond step of the clearing sequence is governed by the state of hnds and oin at the time the second step is performed. although any amount of delay is permitted between the two steps of this clearing sequence, it is best to keep the steps as close together as possible. the arming mechanism is automatically cleared whenever the selected edge is detected at the stra pin. if an edge is recognized after the arming step but before the clearing step, the internal arming signal will be negated, and the clearing step will not clear staf. stai strobe a interrupt enable this control bit determines whether staf will cause interrupts. when stai is one, a hardware interrupt request is generated whenever the staf bit is set. when stai is zero, staf interrupts are inhibited. cwom port c wired-or mode this bit is used to configure all port c outputs for wired-or operation. when cwom is zero, port c outputs operate as active push-pull drivers. when cwom is one, the p-type pull-up devices are disabled, causing port c outputs to act as open-drain driv- pioc parallel i/o control register $1002 bit 7 654321 bit 0 staf stai cwom hnds oin pls ega invb reset: 00000u11
m68hc11 parallel input/output motorola reference manual 7-47 ers. the cwom bit simultaneously affects all eight port c bits. the p-channel device forms a p-n junction between the v dd supply and the output pin so that the pin cannot be pulled more than a diode drop above the v dd supply. for this reason, the wired- or mode cannot be used for level conversion the way open-collector ttl devices are sometimes used. in a ttl system, a brief contention between two push-pull drivers, though not good practice, generally has no serious consequences. in a cmos sys- tem, a brief contention between push-pull drivers can induce destructive latchup. in cases where two cmos output drivers could be in contention, they should be config- ured for wired-or operation. if there is a brief contention between the time one driver is turned on and the other is turned off, there will be no danger of latchup damage. hnds handshake/simple strobe mode select when hnds is zero, the simple strobe mode is selected. in the simple strobe mode, the strb pin is pulsed for two e-clock cycles after each write to port b. also, port c data is asynchronously latched into the portcl register each time the selected edge is detected at the stra pin. when hnds is set to one, either full-input or full-output handshake mode is selected. all full-handshake modes use port c, the stra strobe input pin, and the strb handshake output pin. since the handshake i/o subsystem does not use port b when a full-handshake mode is selected, port b defaults to being a general-purpose output port. oin output/input handshake select this bit has no effect unless hnds is one. when hnds is one, oin further qualifies the handshake mode. when oin is one, full-output handshake is selected. when oin is zero, full-input handshake is selected. pls strobe b pulse mode select this control bit determines whether the strb pin is configured for pulsed or inter- locked operation. in interlocked mode, once strb is asserted, it will remain active un- til an acknowledge edge is detected at the stra pin. the interlocked mode is selected when pls is zero. interlocked mode cannot be specified unless hnds is logic one. in pulsed mode, strb is negated exactly two e-clock cycles after it is asserted. when the simple strobe mode is selected (hnds = 0), the pulsed mode is assumed, even if pls is set to one. additional information about strobe b can be found in 7.3.3 r/w (strb) pin . ega edge select for strobe a this control bit selects which polarity edge will be recognized at the stra input pin. when ega is zero, falling edges are detected and rising edges are ignored. when ega is one, only rising edges are recognized at the stra pin. when the three-state variation of the full-output handshake mode is being used, ega also specifies the level on stra that will cause port c output buffers to be enabled. the output enable for port c pins is an active-high internal signal, which is the exclusive or of ega with the level at the stra pin. thus, the trailing edge of the enable signal on the stra pin will be the selected active edge used by the handshake sequence. invb invert strobe b the strb signal is developed in an s/r flip-flop in the strb pin logic. the invb con- trol bit selects either the q or q output of this flip-flop to be coupled out of the strb
motorola parallel input/output m68hc11 7-48 reference manual pin. if invb is zero, the q of this latch is coupled out of the strb pin, and strb sig- nals are active low. if invb is one, the q of this latch is used, and strb signals are active high. changes to invb do not affect the state of the internal s/r flip-flop. 7.4.5 non-handshake uses of stra and strb pins when not being used for handshake functions, the stra pin can be used as a gener- al-purpose edge-detection interrupt source, which is fairly common use for the stra pin. the staf is set each time a selected edge is recognized. the stai control bit allows strobe a edges to force a maskable interrupt to the irq vector. the ega control bit allows the user to select either rising edges or falling edges as the triggering edge for the strobe a input. though not a very common practice, the strb pin can be used as an extra static out- put. when full-input handshake mode is selected, strb remains at its inactive level until the portcl register is read. if portcl is never read, strb stays at its inactive level indefinitely. the invb control bit allows the user to switch the inactive level from one to zero by writing to the pioc register. in this scheme, it is important never to read the portcl register because this would cause strb to automatically go to its active level. other similar schemes may be developed to meet specific application needs. usually when the stra and strb pins are being used for non-handshake functions, the handshake i/o subsystem would be configured for full-input handshake mode be- cause the other two modes result in interactions between the strobe pins and the port b and c pins. if simple strobe mode is selected, any write to port b will generate a pulse on the strb pin. if full-output handshake is selected, each time the stra pin goes to its selected active level, all port c pins are forced to be outputs (even if the ddrc bits indicate they should be inputs). these interactions are a normal conse- quence of the handshake i/o functions but could interfere with non-handshake use of the stra and strb pins. for this reason, users are encouraged to study the opera- tion of the handshake i/o subsystem carefully if they plan to use stra and strb for non-handshake functions.
m68hc11 synchronous serial peripheral interface motorola reference manual 8-1 section 8 synchronous serial peripheral interface the serial peripheral interface (spi) is one of two independent serial communications subsystems included on the MC68HC11a8. as the name implies, the spi is primarily used to allow the microcontroller unit (mcu) to communicate with peripheral devices. the spi is also capable of interprocessor communications in a multiple-master sys- tem. peripheral devices are as simple as an ordinary transistor-transistor logic (ttl) shift register or as complex as a complete subsystem, such as a liquid crystal diode (lcd) display driver or an analog-to-digital (a/d) converter subsystem. the spi sys- tem is flexible enough to interface directly with numerous standard product peripherals from several manufacturers. the system can be configured as a master or a slave de- vice. data rates as high as 1 mbit per second are accommodated when the system is configured as a master; rates as high as 2 mbits per second are accommodated when the system is operated as a slave. clock control logic allows a selection of clock polarity and a choice of two fundamen- tally different clocking protocols to accommodate most available synchronous serial peripheral devices. when the spi is configured as a master, software selects one of four different bit rates for the serial clock. error-detection logic is included to support interprocessor communications. a write- collision detector indicates when an attempt is made to write data to the serial shift reg- ister while a transfer is in progress. a multiple-master mode-fault detector automatical- ly disables spi output drivers if more than one mcu simultaneously attempts to become bus master. the i/o pin control logic on the MC68HC11a8 is more flexible than that of other mo- torola mcus. this added i/o pin control allows the MC68HC11a8 to implement sys- tems with a single, bidirectional data line or other unusual synchronous serial configurations. 8.1 spi transfer formats during an spi transfer, data is simultaneously transmitted (shifted out serially) and re- ceived (shifted in serially). a serial clock line synchronizes shifting and sampling of the information on the two serial data lines. a slave select line allows individual selection of a slave spi device; slave devices that are not selected do not interfere with spi bus activities. on a master spi device, the slave select line can optionally be used to indi- cate a multiple-master bus contention. 8.1.1 spi clock phase and polarity controls software can select any of four combinations of serial clock (sck) phase and polarity using two bits in the spi control register (spcr). the clock polarity is specified by the cpol control bit, which selects an active high or active low clock and has no signifi-
motorola synchronous serial peripheral interface m68hc11 8-2 reference manual cant effect on the transfer format. the clock phase (cpha) control bit selects one of two fundamentally different transfer formats. the clock phase and polarity should be identical for the master spi device and the communicating slave device. in some cas- es, the phase and polarity are changed between transfers to allow a master device to communicate with peripheral slaves having different requirements. the flexibility of the spi system on the MC68HC11a8 allows direct interface to almost any existing syn- chronous serial peripheral. 8.1.2 cpha equals zero transfer format figure 8-1 is a timing diagram of an spi transfer where cpha is zero. two waveforms are shown for sck: one for cpol equals zero and another for cpol equals one. the diagram may be interpreted as a master or slave timing diagram since the sck, mas- ter in/slave out (miso), and master out/slave in (mosi) pins are directly connected be- tween the master and the slave. the miso signal is the output from the slave, and the mosi signal is the output from the master. the ss line is the slave select input to the slave; the ss pin of the master is not shown but is assumed to be inactive. the ss pin of the master must be high or must be reconfigured as a general-purpose output not affecting the spi. this timing diagram functionally depicts how a transfer takes place; it should not be used as a replacement for data-sheet parametric information. figure 8-1 cpha equals zero spi transfer format 8.1.3 cpha equals one transfer format figure 8-2 is a timing diagram of an spi transfer where cpha is one. two waveforms are shown for sck: one for cpol equals zero and another for cpol equals one. the diagram may be interpreted as a master or slave timing diagram since the sck, miso, and mosi pins are directly connected between the master and the slave. the miso signal is the output from the slave, and the mosi signal is the output from the master. the ss line is the slave select input to the slave; the ss pin of the master is not shown but is assumed to be inactive. the ss pin of the master must be high or must be re- configured as a general-purpose output not affecting the spi. this timing diagram functionally illustrates how a transfer takes place; it should not be used as a replace- ment for data-sheet parametric information. msb 654321lsb * 654321lsb not defined but normally msb of character just received. 2345678 1 msb miso (from slave) mosi (from master) sck (cpol=1) sck (cpol=0) sck cycle # (for reference) ss (to slave) lsb *
m68hc11 synchronous serial peripheral interface motorola reference manual 8-3 figure 8-2 cpha equals one spi transfer format when cpha equals zero, the ss line must be negated and reasserted between each successive serial byte. also, if the slave writes data to the spi data register (spdr) while ss is active low, a write-collision error results. when cpha equals one, the ss line may remain active low between successive transfers (can be tied low at all times). this format is sometimes preferred in systems having a single fixed master and a single slave driving the miso data line. 8.2 spi block diagram figure 8-3 is a block diagram of the spi subsystem. when an spi transfer occurs, an 8-bit character is shifted out one data pin while a different 8-bit character is simulta- neously shifted in a second data pin. another way to view this transfer is that an 8-bit shift register in the master and another 8-bit shift register in the slave are connected as a circular 16-bit shift register. when a transfer occurs, this distributed shift register is shifted eight bit positions; thus, the characters in the master and slave are effectively exchanged. the central element in the spi system is the block containing the shift register and the read data buffer. the system is single buffered in the transmit direction and double buffered in the receive direction. this fact means new data for transmission cannot be written to the shifter until the previous transaction is complete; however, received data is transferred into a parallel read data buffer so the shifter is free to accept a second serial character. as long as the first character is read out of the read data buffer before the next serial character is ready to be transferred, no overrun condition will occur. a single mcu register address is used for reading data from the read data buffer and for writing data to the shifter. not defined but normally lsb of previously transmitted character. 654321 lsb 654321lsb 2345678 1 msb miso (from slave) mosi (from master) sck (cpol=1) sck (cpol=0) sck cycle # (for reference) ss (to slave) msb * *
motorola synchronous serial peripheral interface m68hc11 8-4 reference manual figure 8-3 spi system block diagram 8.3 spi pin signals there are four i/o pin signals associated with spi transfers: the sck, the miso data line, the mosi data line, and the active low ss pin. when the spi system is disabled, the four pins are configured for general-purpose i/o, and the primary direction of data is controlled by a data direction control bit corresponding to each i/o pin. when the spi system is enabled, the data direction control bits still influence the direction of data at the pins. detailed logic for these pins is included in section 7 parallel input/ output . the following rules will answer the most common questions. when the spi system is on and expects a pin to be an input, the pin will be configured as an input regardless of the state of its data direction control bit. when the spi system is on and expects a pin to be an output, the pin will be configured as an output only if its data direction control bit is set to one. when the spi is configured as a master, the pd5/ ss spr0 spr1 cpha cpol mstr dwom spe spie spi control register modf wcol spif spi status register 8/16-bit shift register read data buffer msb lsb internal data bus spi interrupt request mstr spe mstr dwom spe spr0 spi clock (master) spi control select divider internal mcu clock clock logic clock pin control logic s m s m m s miso pd2 mosi pd3 sck pd4 ss pd5 spr1 ? 2 ? 4 ? 16 ? 32 8 8 8
m68hc11 synchronous serial peripheral interface motorola reference manual 8-5 pin is a special case. note spi transfers will not occur unless the outputs are enabled by setting the corresponding ddrd bits. spi outputs are disabled (high imped- ance) unless their corresponding ddrd bits are set to one. spi inputs are configured as high-impedance inputs even if their corre- sponding ddrd bits are set to one. the sck pin is an output when the spi is configured as a master and an input when the spi is configured as a slave. when the spi is configured as a master, the sck signal is derived from the internal mcu bus clock. when the master initiates a transfer, eight clock cycles are automatically generated on the sck pin. when the spi is con- figured as a slave, the sck pin is an input, and the clock signal from the master syn- chronizes the data transfer between the master and slave devices. slave devices ignore the sck signal unless the slave select pin is active low. in both the master and slave spi devices, data is shifted on one edge of the sck signal and is sampled on the opposite edge where data is stable. edge polarity is determined by the spi transfer protocol. the miso and mosi data pins are used for transmitting and receiving serial data. when the spi is configured as a master, miso is the master data input line, and mosi is the master data output line. when the spi is configured as a slave, these pins re- verse roles. in a multiple-master system, all sck pins are tied together, all mosi pins are tied together, and all miso pins are tied together. a single spi device is configured as a master; all other spi devices on the spi bus are configured as slaves. the single master drives data out its sck and mosi pins to the sck and mosi pins of the slaves. one selected slave device optionally drives data out its miso pin to the miso master pin. the automatic control of the direction of these pins makes reconfiguration through external logic unnecessary when a new device becomes the master. the ss pin behaves differently on master and slave devices. on a slave device, this pin is used to enable the spi slave for a transfer. if the ss pin of a slave is inactive (high), the device ignores sck clocks and keeps the miso output pin in the high-im- pedance state. on a master device, the ss pin can optionally serve as an error-detec- tion input for the spi or as a general-purpose output not affecting the spi. the choice is based on the corresponding data direction control bit (ddrd5). when ddrd5 is logic one and the spi is configured as a master, the pd5/ ss pin acts as a general- purpose output that is independent of spi activities. when the ddrd5 bit is logic zero and the spi system is configured as a master, the ss pin acts as an error-detection input, which should remain high. if the ss pin goes low while the spi is a master and is using the ss pin as an error-detection input, it indicates that some other device on the spi bus is attempting to be a master. this attempt causes the master device sens- ing the error to immediately exit the spi bus to avoid potentially damaging driver con- tentions. this detection is called a mode fault and is discussed in 8.5.1 spi mode- fault error . the port d i/o pins, including the four spi pins, can be configured to behave as open-
motorola synchronous serial peripheral interface m68hc11 8-6 reference manual drain drivers. the port d wired-or mode (dwom) control bit is used to enable this option. an external pull-up resistor is required on each port d output pin while this op- tion is selected. in multiple-master systems, this option provides extra protection against cmos latchup because, even if more than one spi device tries to simulta- neously drive the same bus line, there will be no destructive contention. other unusual spi system configurations also benefit from this option (e.g., when miso and mosi are tied together to form a single, bidirectional data line). 8.4 spi registers the spi control register (spcr), spi status register (spsr), and spdr are software- accessible registers used to configure and operate the spi system. because the port d data direction control register (ddrd) influences spi activities, it will be discussed briefly. detailed logic diagrams of the port d pins can be found in section 7 par- allel input/output . 8.4.1 port d data direction control register (ddrd) this register, which may be read or written at any time, is used to control the primary direction of port d pins. bits 5, 4, 3, and 2 of port d are used by the spi system when the spi enable (spe) control bit is one. the serial communications interface (sci) sys- tem uses the other two bits of port d when the sci receiver and transmitter are en- abled. this description of ddrd is only intended to cover material related to the spi system. ddrd5 data direction control for port d bit 5 ( ss) when the spi system is enabled as a slave (spe = 1; mstr = 0), the pd5/ ss pin is the slave select input, regardless of the value of ddrd5. when the spi system is en- abled as a master (spe = 1; mstr = 1), the function of the pd5/ ss pin depends on the value in ddrd5. 0 = the ss pin is used as an input to detect mode-fault errors. a low on this pin indicates that some other device in a multiple-master system has become a master and is trying to select this mcu as a slave. to prevent harmful conten- tions between output drivers, a mode fault is generated, which causes the de- vice sensing the fault to immediately change all of its spi pins to high impedance. additional information on mode faults is given in 8.5.1 spi mode- fault error . 1 = the pd5/ ss pin acts as a general-purpose output not affected by the spi sys- tem. because the mode-fault detection logic in the spi is disabled, changing this pd5 output pin to zero does not affect the spi system. ddrd4 data direction control for port d bit 4 (sck) ddrd port d data direction register $1009 bit 7 654321 bit 0 ddrd5 ddrd4 ddrd3 ddrd2 ddrd1 ddrd0 reset: 00000000 refer- ence: ts sck mosi miso txd rxd
m68hc11 synchronous serial peripheral interface motorola reference manual 8-7 when the spi system is enabled as a slave, the pd4/sck pin acts as the spi serial clock input, regardless of the state of ddrd4. when the spi system is enabled as a master, the ddrd4 bit must be set to one to enable the sck output. ddrd3 data direction control for port d bit 3 (mosi) when the spi system is enabled as a slave, the pd3/mosi pin acts as the slave serial data input, regardless of the state of ddrd3. when the spi system is enabled as a master, the ddrd3 bit must be set to one to enable the master serial data output. if a master device wants to initiate an spi transfer to receive a byte of data from a slave without transmitting a byte, it might purposely leave the mosi output disabled. spi systems that tie mosi and miso together to form a single bidirectional data line also need to selectively disable the mosi output. ddrd2 data direction control for port d bit 2 (miso) when the spi system is enabled as a slave, the ddrd2 bit must be set to one to en- able the slave serial data output. a master spi device can simultaneously broadcast a message to several slaves as long as no more than one of the slaves tries to drive the miso line. spi systems that tie mosi and miso together to form a single bidirec- tional data line also need to selectively disable the miso output. when the spi system is enabled as a master, the pd2/miso pin acts as the master serial data input, regardless of the state of ddrd2. 8.4.2 spi control register (spcr) this register, which may be read or written at any time, is used to configure the spi system. the ddrd register must also be properly configured before spi transfers can occur. spie spi interrupt enable 0 = spi interrupts are disabled. polling is used to sense the spif and modf flags. 1 = spi interrupt is requested if spif or modf set (provided i bit in condition code register (ccr) is zero). spe spi system enable 0 = spi system is off. 1 = spi system is on. dwom port d wired-or mode select 0 = port d outputs are push-pull. 1 = p-channel pull-ups on all six port d output drivers are disabled so port d outputs act as open-drain drivers. mstr master/slave mode select 0 = spi is configured as a slave. spcr spi control register $1028 bit 7 654321 bit 0 spie spe dwom mstr cpol cpha spr1 spr0 reset: 000001uu
motorola synchronous serial peripheral interface m68hc11 8-8 reference manual 1 = spi is configured as a master. cpol clock polarity select 0 = active high clocks selected; sck idles low. 1 = active low clocks selected; sck idles high. cpha clock phase select this control bit selects one of two fundamentally different transfer formats (see 8.1 spi transfer formats ). spr1, spr0 spi bit rate select the following table shows the relationship between the spr1 and spr0 control bits and the bit rate for transfers when the spi is operating as a master. when the spi is operating as a slave, the serial clock is input from the master; therefore, the spr1 and spr0 control bits have no meaning. 8.4.3 spi status register (spsr) this read-only register contains status flags indicating the completion of an spi trans- fer and the occurrence of certain spi system errors. the flags are automatically set by the occurrence of the corresponding spi events; the flags are cleared by automatic software sequences. spif spi transfer complete flag this flag is automatically set to one at the end of an spi transfer. spif is automatically cleared by reading the spsr with spif set, followed by an access of the spdr. the definition of end of a transfer varies with master versus slave and the transfer format specified by cpha. this subject is discussed in 8.6 beginning and ending spi transfers . wcol write collision error flag this flag is automatically set if the spdr is written while a transfer is in progress. wcol is automatically cleared by reading the spsr with wcol set, followed by an access of the spdr. the details of when a transfer technically begins and ends de- pend on the configuration of the spi system, which is discussed in 8.6 beginning and ending spi transfers . spr1 spr0 e clock divided by 002 014 1016 1132 spsr spi status register $1029 bit 7 654321 bit 0 spif wcol modf reset: 00000000
m68hc11 synchronous serial peripheral interface motorola reference manual 8-9 bit 5 not implemented; always reads zero. modf mode-fault error flag this flag is set if the ss signal goes to active low while the spi is configured as a mas- ter (mstr = 1). modf is automatically cleared by reading the spsr with modf set, followed by a write to the spcr. because the mode-fault mechanism is intended to prevent damage due to conflicts between output drivers, it takes effect immediately, regardless of the spi system configuration at the time of the fault. the mstr control bit in the spcr and all four ddrd control bits associated with the spi are cleared, and an interrupt is generated subject to masking by the spie control bit and the i bit in the ccr. mode-fault errors are discussed in greater detail in the following para- graphs. bits [3:0] not implemented; always read zero. 8.5 spi system errors two system errors can be detected by the spi system in the MC68HC11a8. the first type error arises in a multiple-master system when more than one spi device simulta- neously tries to be a master. this error is called a mode fault. the second type error, a write collision, indicates that an attempt has been made to write data to the spdr while a transfer was in progress. 8.5.1 spi mode-fault error when the spi system is configured as a master and the ss input line goes to active low, a mode-fault error has occurred. only an spi master can experience a mode-fault error, caused when a second spi device becomes a master and selects this device as if it were a slave. in cases where more than one device is concurrently configured as a master, there is a chance of contention between two pin drivers. for push-pull cmos drivers, this contention can cause catastrophic latchup. when this type error is detect- ed, the following actions are taken immediately: 1. the ddrd bits corresponding to the four spi-related i/o pins are forced to zero to disable all spi output drivers. 2. the mstr control bit is forced to zero to reconfigure the spi as a slave. 3. the spe control bit is forced to zero to disable the spi system. 4. the modf status flag is set, and an spi interrupt is generated subject to mask- ing by the spie bit and the i bit in the ccr. after software has corrected the problems that led to the mode fault, modf is cleared and the system is returned to normal operation. the modf flag is automatically cleared by reading spsr while modf is set, followed by a write to the spdr. the ddrd must also be restored before spi transfers can resume. in some cases, the mode-fault mechanism does not fully protect multiple-master sys- tems from driver contention. for example, suppose a second device becomes a mas- ter but does not immediately drive the ss pin of this master low. perhaps a system fault selects two slave devices, and these slave devices try to simultaneously drive the
motorola synchronous serial peripheral interface m68hc11 8-10 reference manual miso line. both these cases result in output driver contentions, but neither causes a mode-fault error. too many system configurations are possible to discuss all the pos- sibilities, but some suggestions will help the system designer find practical ways to prevent problems. under normal conditions, a moderate resistance, (i.e., 1 to 10k ohms) in series with an spi pin does not adversely affect spi transfer operations. if a driver contention oc- curs, this series resistance will protect the drivers against latchup. another way to pro- tect against latchup would be to employ the dwom option, which transforms the spi output drivers into open-drain-type drivers. when the dwom option is selected, it af- fects all six port d pins; therefore, pull-up resistors are needed on the pd0 and pd1 pins if they are being used as outputs. both of these suggestions affect the maximum usable data rate, depending on the loading capacitance on the spi lines. 8.5.2 spi write-collision errors a write collision occurs if the spdr is written while a transfer is in progress. since the spdr is not double buffered in the transmit direction, writes to spdr cause data to be written directly into the spi shift register. because this write corrupts any transfer in progress, a write-collision error is generated. the transfer continues undisturbed, and the write data that caused the error is not written to the shifter. a write collision is normally a slave error because a slave has no control over when a master will initiate a transfer. a master knows when a transfer is in progress; thus, there is no excuse for a master to generate a write-collision error, although the spi log- ic can detect write collisions in a master as well as in a slave. the details of what constitutes a transfer in progress depend on the spi configuration. for a master, a transfer starts when data is written to spdr and ends when spif is set. for a slave with cpha equals zero, a transfer starts when ss goes low and ends when ss returns high. in this instance, spif is set at the middle of the eighth sck cy- cle when data is transferred from the shifter to the parallel data register, but the trans- fer is still in progress until ss goes high. for a slave with cpha equals one, a transfer starts when the sck line goes to its active level, which is the edge at the beginning of the first sck cycle. the transfer ends in a slave in which cpha equals one when spif is set. 8.6 beginning and ending spi transfers the two basic spi transfer formats are described in 8.1 spi transfer formats .a transfer includes the eight sck cycles plus an initiation period at the beginning and ending period of the transfer. the details of the beginning and ending periods depend on the cpha format selected and whether the spi is configured as a master or a slave. the initiation delay period is also affected by the spi clock rate selection when the spi is configured as a master. it may be useful to refer to the transfer format illustrated in figure 8-1 and figure 8-2 to understand how the beginning and ending details fit into a complete transfer oper- ation.
m68hc11 synchronous serial peripheral interface motorola reference manual 8-11 8.6.1 transfer beginning period (initiation delay) all spi transfers are started and controlled by a master spi device. as a slave, the MC68HC11a8 considers a transfer to begin with the first sck edge or the falling edge of ss, depending on the cpha format selected. when cpha equals zero, the falling edge of ss indicates the beginning of a transfer. when cpha equals one, the first edge on the sck indicates the start of the transfer. in either cpha format, a transfer can be aborted by taking the ss line high, which causes the spi slave logic and bit counters to be reset. the sck rate selected has no effect on slave operations since the clock from the master is controlling transfers. when the spi is configured as a master, transfers are started by a software write to the spdr. cpha has no effect on the delay to the start of the transfer, but it does af- fect the initial state of the sck signal. when cpha equals zero, the sck signal re- mains inactive for the first half of the first sck cycle. when cpha equals one, the first sck cycle begins with an edge on the sck line from its inactive to its active level. the spi clock rate (selected by spr[1:0]) affects the delay from the write to spdr and the start of the spi transfer (see figure 8-4 ). the internal spi clock in the master is a free- running derivative of the internal mcu clock (ph2). sck edges occur a small propa- gation delay after the rising edge of ph2. the rising edge of ph2 occurs at the middle of the e-clock low period. since the spi clock is free-running, there is an uncertainty about where the write to spdr will occur relative to the slower sck. this uncertainty causes the variation in the initiation delay shown in figure 8-4 .
motorola synchronous serial peripheral interface m68hc11 8-12 reference manual figure 8-4 delay from write spdr to transfer start (master) 8.6.2 transfer ending period an spi transfer is technically complete when the spif flag is set, but, depending on the configuration of the spi system, there may be additional tasks. because the spi bit rate does not affect timing of the ending period, only the fastest rate will be consid- ered in discussions of the ending period. when the spi is configured as a master, spif is set at the end of the eighth sck cycle. when cpha equals one, sck is inactive for the last half of the eighth sck cycle. fig- ure 8-5 shows the transfer ending period for a master. the sck waveforms in this fig- ure show only the cpol equals zero case, since clock polarity does not affect timing of the ending period. min max e cycle where spdr written max min max min max sck=e ? 32 sck=e ? 16 sck=e ? 4 sck=e ? 2 sck cycle number sck (cpha=0) sck (cpha=1) mosi e write to spdr initiation delay msb bit 6 12 inset: detailed view of initiation delay from write spdr to transfer begin. possible transfer start points
m68hc11 synchronous serial peripheral interface motorola reference manual 8-13 figure 8-5 transfer ending for an spi master when the spi is operating as a slave, the ending period is different because the sck line can be asynchronous to the mcu clocks of the slave and because the slave does not have access to as much information about sck cycles as the master. for exam- ple, when cpha equals one, where the last sck edge occurs in the middle of the eighth sck cycle, the slave has no way of knowing when the end of the last sck cycle is. for these reasons, the slave considers the transfer complete after the last bit of se- rial data has been sampled, which corresponds to the middle of the eighth sck cycle. a synchronization delay is required so the setting of the spif flag is properly posi- tioned relative to the internal ph2 clock of the slave. figure 8-6 shows the ending pe- riod for a slave. the sck waveforms in this figure show only the cpol equals zero case, since clock polarity does not affect timing of the ending period. sck cycle # sck (cpha=0) sck (cpha=1) 78 pc (low) pc (high) earliest possible stacking due to spif interrupt (no other interrupt pending) spif set e new opcode (not executed due to interrupt) r/ w ???
motorola synchronous serial peripheral interface m68hc11 8-14 reference manual figure 8-6 transfer ending for an spi slave when cpha equals zero, there is a potential problem that can be avoided by proper software but is sometimes overlooked. the spif flag is set at the end of a transfer, but the slave is not permitted to write new data to the spdr while the ss line is still low. if the master device is busy, the ss line to the slave can remain low longer than the slave expects. the proper way for the slave to manage this problem is to read the state of the port d bit 5 pin, ( ss), before writing to spdr. if this procedure is not followed (slave mode and cpha = 0) and an attempt is made to write to spdr before ss goes high, a write collision will result. 8.7 transfers to peripherals with odd word lengths the spi system in the MC68HC11a8 is oriented toward 8-bit transfers, but not all pe- ripherals use eight bits. some peripherals use multiples of eight bits, but a few use odd word lengths. when a peripheral uses an odd number of bits, it is usually possible to send it some multiple of eight bits, and the peripheral will ignore the extra bits. serial peripherals are commonly designed for cascading. in these devices, only the most re- cent bits received will be important, and extra leading bits pass through the peripheral. in more unusual peripheral designs, the leading bits can alter the way the peripheral will interpret the remaining bits in a serial stream. in all cases, the requirements of each peripheral in the system must be considered. the mc144110 six-channel, 6-bit, d/a converter peripheral is an example of a periph- eral with an odd word length. this device requires six 6-bit words (a total of 36 bits) to update all six channels. the following examples show two possible approaches for managing this device to illustrate some of the possible trade-off decisions found in un- sck (cpha=1) last edge sck (cpha=0) second last edge pc (low) pc (high) earliest possible stacking due to spif interrupt (no other interrupt pending) spif set e new opcode (not executed due to interrupt) synchronization uncertainty r/ w ???
m68hc11 synchronous serial peripheral interface motorola reference manual 8-15 usual peripherals. the hardware hookup, which is identical for both examples, is shown in figure 8-7 . a software program includes the routines needed for both exam- ples. figure 8-8 shows the register definitions and ram variables used by both exam- ple programs. figure 8-7 hardware hookup for examples 8C1 and 8C2 d d dd v MC68HC11evb board 3 2 5 4 7 17 12 11 14 13 16 15 r1 q1 r2 q2 r3 q3 r4 q4 r5 q5 r6 q6 measure with high-impedance voltmeter clk in out 1 10 18 8 en mc144110 d/a p1-26 p1-24 p1-23 p1-1 p1-25 clk pd3/mosi pd5/ ss v ss note: pin numbers on p1 of the MC68HC11evb board are the same as those for a 52-pin MC68HC11a8. dd v dd v dd v v ss 6
motorola synchronous serial peripheral interface m68hc11 8-16 reference manual * register definitions for 68hcll registers (used for ex 8-1 & 8-2) 1008 portd equ $1008 port d data register * " - , - ,ss* ,sck ;mosi,miso,txd ,rxd " 1009 ddrd equ $1009 port d data direction 1028 spcr equ $1028 spi control register * "spie,spe ,dwom,mstr;cpol,cpha,spr1,spr0" 1029 spsr equ $1029 spi status register * "spif,wcol, - ,modf; - , - , - , - " 102a spdr equ $102a spi data register; read-buffer; write-shifter * ram variables (dax used by ex 8-1 & 8-2, spix used only by 8-1) 0000 da1 equ $00 6-bit val for d/a ch 1 "-,-,15,14;13,12,11,10" 0001 da2 equ $01 6-bit val for d/a ch 2 "-,-,25,24;23,22,21,20" 0002 da3 equ $02 6-bit val for d/a ch 3 "-,-,35,34;33,32,31,30" 0003 da4 equ $03 6-bit val for d/a ch 4 "-,-,45,44;43,42,41,40" 0004 da5 equ $04 6-bit val for d/a ch 5 "-,-,55,54;53,52,51,50" 0005 da6 equ $05 6-bit val for d/a ch 6 "-,-,65,64;63,62,61,60" * upper 2 bits of dax should be 0 but will be ignored. 0006 spi1 equ $06 spi packed byte 1 "--,--,--,--;65,64,63,62" 0007 spi2 equ $07 spi packed byte 2 "61,60,55,54;53,52,51,50" 0008 spi3 equ $08 spi packed byte 3 "45,44,43,42;41,40,35,34" 0009 spi4 equ $09 spi packed byte 4 "33,32,31,30;25,24,23,22" 000a spi5 equ $0a spi packed byte 5 "21,20,15,14;13,12,11,10" * note: upper 4 bits of spi1 are unused extras but will be 0. figure 8-8 register definitions and ram variables for examples 8C1 and 8C2 8.7.1 example 8C1: on-chip spi driving an mc144110 d/a in this example, software must reformat (pack) the six 6-bit data values into five 8-bit words, which can then be transferred to the mc144110 d/a using the on-chip spi. fig- ure 8-9 is the software listing for the example 8C1 routines. in the example 8C1 setup, the mcu is running at 2-mhz e-clock frequency. to meet the timing requirements of the mc144110 d/a, the slowest spi clock rate (e ? 32) is used. figure 8-10 shows a detailed analysis of important timing parameters. these timing details are derived from knowledge of the cycle-by-cycle activity of software in- structions and detailed spi system timing. this timing analysis depicts the strong in- terdependence of software and hardware in mcu systems. 8.7.2 example 8C2: software spi driving an mc144110 d/a sometimes it is easier and/or more efficient to use software to emulate an spi to allow even more flexibility than the on-chip spi system allows (e.g., odd word lengths). as example 8C2 shows, it is not necessarily difficult to manipulate i/o pins to create an spi-like interface. in this example, a software spi allows 6-bit transfers so the six d/a values can be used without any packing or reformatting (needed in the previous ex- ample). figure 8-11 is the software listing for example 8C2.
m68hc11 synchronous serial peripheral interface motorola reference manual 8-17 ********************************************************************** * example 8-1 * * this example program uses the on-chip hardware spi to drive an * * mc144110 six channel d to a converter peripheral. * * to try ex 8-1, connect mc144110 to port d pins on evb, load * * program into evb ram, manually enter data for da1 to da6 and * * execute a go to $cooo. * ********************************************************************* c000 org $c000 start of users ram in evb c000 be cf ff [3] init1 lds #$cfff top of c page ram c003 86 2f [2] ldaa #$2f * ss*-hi, sck-lo, mosi-hi c005 b7 10 08 [4] staa portd so ss* stays high when ddrd5 set c008 86 38 [2] ldaa #$38 -,-,1,1;1,0,0,0 c00a b7 10 09 [4) staa ddrd ss*, sck, mosi - outs * miso, txd, rxd - ins * ddrd5=1 so ss* pin is a general-purpose output c00d 86 57 [2] ldaa #$57 c00f b7 10 28 [4] staa spcr spi on as master, cpha=1, cpol=0 * e/32 clk rate *** * following two instructions call main routine for ex 8-1 *** c012 8d 38 [6] bsr updat1 xfer 5 8-bit words to mc144110 c014 7e e0 00 [3] jmp $e000 restart buffalo *** c04c 3c [4] updat1 pshx save registers x and a c04d 18 3c [5] pshy c04f 36 [3] psha c050 8d c5 [6] bsr reform reformat data so spi can xfer it c052 ce 00 06 [3] ldx #spi1 point at 1st byte to send via spi c055 18 ce 10 00[4] ldy #$1000 point at on-chip registers c059 18 1d 08 20[8] bclr portd,y %00100000 drive ss* low c05d a6 00 [4] tfrlp1 ldaa 0,x get a byte to transfer via spi c05f b7 10 2a [4] staa spdr write spi data reg to start xfer c062 b6 10 29 [4] wait1 ldaa spsr loop to wait for spif c065 2a fb [3] bpl wait1 spif is in msb of spsr * (when spif set, spsr neg) c067 08 [3] inx point to next spi byte c068 0c 00 0b [4] cpx #spi5+1 done yet ? c06b 26 f0 [3] bne tfrlp1 if not, tfr another byte c06d 18 1c 08 20[8] bset portd,y %00100000 drive ss* high c071 32 [4] pula when done, restore regs x, y & a c072 18 38 [6] puly c074 38 [5] pulx c075 39 [5] rts ** return ** figure 8-9 example 8C1 software listing (sheet 1 of 2)
motorola synchronous serial peripheral interface m68hc11 8-18 reference manual ******************************************************************************** * reform - this subroutine reformats six 6-bit values into five 8-bit * * values so they can be sent by the spi system. * * * * the mc144110 needs 36 bits of information, which is not a multiple * * of 8 bits; however, we can send five 8 bit words (40 bits) and the * * mc144110 will use only the last 36 bits. * * * * original format change to this format * * da1 "-,-,15,14;13,12,11,10" spi1 "--,--,--,--;65,64,63,62" * * da2 "-,-,25,24;23,22,21,20" spi2 "61,60,55,54;53,52,51,50" * * da3 "-,-,35,34;33,32,31,30" spi3 "45,44,43,42;41,40,35,34" * * da4 "-,-,45,44;43,42,41,40" spi4 "33,32,31,30;25,24,23,22" * * da5 "-,-,55,54;53,52,51,50" spi5 "21,20,15,14;13,12,11,10" * * da6 "-,-,65,64;63,62,61,60 * ******************************************************************************** c017 37 [3] reform pshb save registers b and a c018 36 [3] psha c019 96 00 [3] idaa da1 a="--,--,15,14;13,12,11,10" c01b 48 [2] asla a="--,15,14,13;12,11,10, 0" c01c 48 [2] asla a="15,14,13,12;11,10, 0, 0" c01d d6 01 [3] ldab da2 b="--,--,25,24;23,22,21,20" c01f c4 3f [2] andb #$3f b=" 0, 0,25,24;23,22,21,20" c021 54 [2] lsrb b=" 0, 0, 0,25;24,23,22,21" c="20 c022 46 [2] rora a="20,15,14,13;12,11,10, 0" c023 54 [2] lsrb b=" 0, 0, 0, 0;25,24,23,22" c="21 c024 46 [2] rora a="21,20,15,14;13,12,11,10" c025 97 0a [3] staa spi5 spi5 is done c027 d7 09 [3] stab spi4 spi4 intermediate value c029 96 03 [3] ldaa da4 a="--,--,45,44;43,42,41,40" c02b d6 02 [3] ldab da3 b="--,--,35,34;33,32,31,30" c02d 58 [2] aslb b="--,35,34,33;32,31,30, 0" c02e 58 [2] aslb b="35,34,33,32;31,30, 0, 0" c02f 58 [2] aslb b="34,33,32,31;30, 0, 0, 0" c="35 c030 49 [2] rola a="--,45,44,43;42,41,40,35" c031 58 [2] aslb b="33,32,31,30; 0, 0, 0, 0" c="34 c032 49 [2] rola a="45,44,43,42;41,40,35,34" c033 da 09 [3] orab spi4 b="33,32,31,30;25,24,23,22" c035 d7 09 [3] stab spi4 spi4 now complete c037 97 08 [3] staa spi3 spi3 done c039 96 04 [3] ldaa da5 a="--,--,55,54;53,52,51,50" c03b 48 [2] asla a="--,55,54,53;52,51,50, 0" c03c 48 [2] asla a="55,54,53,52;51,50, 0, 0" c03d d6 05 [3] ldab da6 b="--,--,65,64;63,62,61,60" c03f c4 3f [2] andb #$3f b=" 0, 0,65,64;63,62,61,60" c041 54 [2] lsrb b=" 0, 0, 0,65;64,63,62,61" c="60 c042 46 [2] rora a="60,55,54,53;52,51,50, 0" c043 54 [2] lsrb b=" 0, 0, 0, 0;65,64,63,62" c="61 c044 46 [2] rora a="61,60,55,54;53,52,51,50" c045 97 07 [3] staa spi2 spi2 done c047 d7 06 [3] stab spi1 spi1 done c049 32 [4] pula restore registers a and b c04a 33 [4] pulb c04b 39 [5] rts ** return ** figure 8-9 example 8C1 software listing (sheet 2 of 2)
m68hc11 synchronous serial peripheral interface motorola reference manual 8-19 figure 8-10 timing analysis for example 8C1 6 e cycles delay; en low to clk (min 11.5 m s/max 19.5 m s) e ldaa 0,x 15 to 31 e cycles (see figure 8-4) a) en low to clock start delay (mc144110 needs 5 m s) bne tfrlp1 c) last sck edge to en release timing (mc144110 needs 5 m s) b) data valid vs. clock timing (mc144110 needs 1 m s setup/ 5 m s hold) cpx #sp15+1 bclr portd,x $20 staa spdr en sck last sck edge to en release (min 19.5 m s/max 22.5 m s) e ldaa spsr earliest read of spif = 1 sck ss ~8 m s setup mosi sck valid data ~8 m s hold bset portd,x $40 inx bpl wait1 ? ? ? ldaa spsr inx bpl wait1 ldaa spsr bpl wait1 spif not set yet spif set now spif set now (refer to figure 8-5 for spi transfer ending details) longest case shortest case (varies with sck alignment to software) ~8 m s
motorola synchronous serial peripheral interface m68hc11 8-20 reference manual **************************************************************************** * example 8-2 * * * * this example program uses a software equivalent of the spi to * * drive an mc144110 six channel d to a converter peripheral. the * * physical hookup is the same as that of the previous example to make * * comparisons easier. * * * * to try ex 8-2, connect mc144110 to port d pins on evb, load * * program into evb ram, manually enter data for da1 to da6 and * * execute a go to $ci00 * **************************************************************************** c100 org $c100 c100 8e cf ff [3] init2 lds #$cfff top of c page ram c103 86 2f [2] ldaa #$2f -,-,1,0;1,1,1,1 c105 b7 10 08 [4] staa portd pd5/ss*-lo,pd4/sck-lo,pd3/mosi-hi c108 86 38 [2] ldaa #$38 -,-,1,1;1,0,0,0 c10a b7 10 09 [4] staa ddrd pd5, pd4, pd3 =outs; others =ins c10d 86 04 [2] ldaa #$04 * "spie,spe,dwom,mstr;cpol,cpha,spr1,spr0" c10f b7 10 28 [4] staa spcr make sure spi off *** * following two instructions call main routine for ex 8-2 *** c112 8d 03 [6] bsr updat2 xfer six 6 bit words to mc144110 c114 7e e0 00 [3] jmp $e000 restart buffalo *** c117 3c [4] updat2 pshx save x, y and a c118 18 3c [5] pshy c11a 36 [3] psha c11b 18 ce 00 05[4] ldy #da6 point at 1st d/a value to xfer. c11f ce 10 00 [3] ldx #$1000 point at register area. c122 86 20 [2] tfrlp2 ldaa #$20 1st pntr to msb of 6 bit data val c124 1d 08 20 [7] bclr portd,x %00100000 pd5(ss*) falling edge c127 01 [2] nop need more dly for mc144110 specs. c128 01 [2] nop c129 1c 08 10 [7] nxtbit bset portd,x %00010000 pd4(sck) rising edge c12c 18 a5 00 [5] bita 0,y test sense of bit to be sent c12f 27 05 [3] beq zbit if zero skip around c131 1c 08 08 [7] bset portd,x %00001000 pd3(mosi) hi bit c134 20 05 [3] bra endbit c136 1d 08 08 [7] zbit bclr portd,x %00001000 pd3(mosi) lo bit c139 20 00 [3] bra endbit want lo time to match hi time c13b 1d 08 10 [7] endbit bclr portd,x %00010000 pd4(sck) falling edge c13e 44 [2] lsra pointer to nxt lower bit position c13f 26 e8 [3] bne nxtbit done if pointer shifted past lsb c141 18 09 [4] dey point at next value to send c143 18 8c ff ff[5] cpy #da1-1 done yet? c147 26 db [3] bne tfrlp2 if not go back to top of loop c149 1c 08 20 [7] bset portd,x %00100000 pd5(ss*) rising edge c14c 32 [4] pula restore x, y and a c14d 18 38 [6] puly c14f 38 [5] pulx c150 39 [5] rts ** return ** figure 8-11 example 8C2 software listing
m68hc11 synchronous serial peripheral interface motorola reference manual 8-21 figure 8-12 shows a detailed analysis of important timing parameters. these timing details are derived from knowledge of the cycle-by-cycle activity of software instruc- tions. this timing analysis illustrates the strong interdependence of software and hard- ware in mcu systems. (a) en low to sck start delay (mc144110 needs 5 m s) (b) data to sck setup (mc144110 needs 1 m s) figure 8-12 timing analysis for example 8C2 (sheet 1 of 2) delay; en low to clk (5.5 m s) e nop bclr portd,x $20 bita 0,y en sck ? ? ? nop bset portd,x $10 ~5 m s setup e bra endbit bset portd,x $10 sck mosi ? ? ? bset portd,x $08 bclr portd,x $10 bclr portd,x $08 beq zbit bita 0,y
motorola synchronous serial peripheral interface m68hc11 8-22 reference manual (c) data hold vs. sck (mc144110 needs 5 m s) (d) sck low to en hold (mc144110 needs 5 m s) figure 8-12 timing analysis for example 8-2 (sheet 2 of 2) data hold (13.5 m s) e lsra bclr portd,x $10 sck mosi bita 0,y bset portd,x $10 beq zbit bset portd,x $08 bclr portd,x $08 bne nxtbit sck to en hold (12 m s) e cpy #da1 1 bclr portd,x $10 sck en bne tfrlp2 bset portd,x $20 lsra bne nxtbit dey
m68hc11 asynchronous serial communications interface motorola reference manual 9-1 section 9 asynchronous serial communications interface this section describes the universal asynchronous receiver transmitter (uart) type serial communications interface (sci) system, which is one of two independent serial i/o subsystems in the m68hc11. the other serial i/o subsystem (called spi) provides for high-speed synchronous serial communication to peripherals or other microcontrol- ler units (mcus), usually located on the same printed circuit board as the m68hc11. this sci system can be used to connect a crt terminal or personal computer to the mcu, or several widely distributed mcus can use their sci subsystems to form a se- rial communication network. 9.1 general description the sci is a full-duplex uart-type asynchronous system, using standard non-return- to-zero (nrz) format (one start bit, eight or nine data bits, and a stop bit). an on-chip baud rate generator derives standard baud-rate frequencies from the mcu oscillator. both the transmitter and the receiver are double buffered; thus, back-to-back charac- ters can be handled easily, even if the central processing unit (cpu) is delayed in re- sponding to the completion of an individual character. the sci transmitter and receiver are functionally independent but use the same data format and baud rate. in this reference manual, baud rate and bit rate are used synonymously. the user will usually have to provide external level-shifter buffers to translate the rs232 or rs422 levels (typically 12 v) to the 0- to 5-v logic levels used by the mcu. this sci receiver includes a number of advanced features to assure high-reliability data reception and to assist development of efficient communications networks. the m68hc11 resynchronizes the receiver bit clock on all one-to-zero transitions in the bit stream rather than just at the beginning of the start bit time; therefore, differences in baud rate between the sending device and the mcu are not as likely to cause recep- tion errors. three logic-level samples are taken near the middle of each bit time, and majority logic decides the sense for the bit. even if noise causes one of these samples to be incorrect, the bit will still be received correctly. the receiver also has the ability to enter a temporary standby mode (called receiver wake up) to ignore messages in- tended for a different receiver. logic automatically wakes up the receiver in time to see the first character of the next message. this wake-up feature greatly reduces cpu overhead in multi-drop sci networks. the sci transmitter can produce queued characters of idle (whole characters of all logic one) and break (whole characters of all logic zero). in addition to the usual trans- mit data register empty (tdre) status flag, this sci also provides a transmit complete (tc) indication that can be used in applications with a modem. 9.1.1 transmitter block diagram figure 9-1 is a block diagram of the transmitter section of the sci subsystem. the de-
motorola asynchronous serial communications interface m68hc11 9-2 reference manual scription given in the following paragraphs is an overview; a more detailed discussion of the sci transmitter is given in 9.3 sci transmitter . figure 9-1 sci transmitter block diagram the heart of the transmitter is the transmit serial shift register near the top of the figure. usually, this shift register gets its data from the write-only transmit buffer. data gets fe nf or idle rdrf tc tdre scsr interrupt status sbk rwu re te ilie rie tcie tie sccr2 sci control 2 transmitter control logic tcie tc tie tdre sci rx requests sci interrupt request internal data bus pin buffer and control h(8)76543210l 10 (11) - bit tx shift register ddd1 pd1 txd scdr tx buffer transfer tx buffer shift enable jam enable preamblejam 1s breakjam 0s (write only) force pin direction (out) size 8/9 wake m t8 r8 sccr1 sci control 1 transmitter baud rate clock 8 8 8
m68hc11 asynchronous serial communications interface motorola reference manual 9-3 into the transmit buffer when software writes to the sci data register (scdr). when- ever data is transferred into the shifter from the transmit buffer, a zero is loaded into the least significant bit (lsb) of the shifter to act as a start bit, and a logic one is loaded into the last bit position to act as a stop bit. in the case of a preamble, the shifter is jammed to all ones, including the bit position usually holding the logic zero start bit. a preamble is jammed each time the transmit enable bit is written from zero to one. in the case of a send break command, the shifter is jammed to all zeros, including the last bit position usually holding the logic one stop bit. the t8 bit in sci control register 1 (sccr1) acts like an extra high-order bit (ninth bit) of the transmit buffer register. this ninth bit is only used if the m bit in sccr1 is one to select the 9-bit data character format. the m bit also controls the length of idle and break characters. the r8 and wake bits in sccr1 are associated with the sci re- ceiver and are only shown in figure 9-1 for reference. the pin buffer logic is quite flexible and useful in some sci systems. this block diagram is not detailed enough to show all of the functions of this block. 9.3.6 txd pin buffer logic describes this logic in greater detail, and a complete mos transistor-lev- el schematic and explanation of this logic is included in 7.3.6.2 pd1 (txd) pin logic . the status flag and interrupt generation logic is shown in figure 9-1 . the tdre and tc status flags in the sci status register (scsr) are automatically set by the trans- mitter logic. these two bits can be read at any time by software. the transmit interrupt enable (tie) and transmit complete interrupt enable (tcie) interrupt control bits en- able the tdre and tc bits, respectively, to generate sci interrupt requests. 9.1.2 receiver block diagram figure 9-2 is a block diagram of the receiver section of the sci subsystem. the de- scription given in the following paragraphs is an overview; a more detailed discussion of the sci receiver is given in 9.4 sci receiver . sci receive data comes in the rxd pin, is buffered, and drives the data recovery block. the data recovery block is actually a high-speed shifter operating at 16 times the bit rate; whereas, the main-receive serial shifter operates at one times the bit rate. this higher speed sample rate allows the start-bit leading edge to be located more accu- rately tha na1x clock would allow. the high-speed clock also allows several samples to be taken within a bit time so logic can make an intelligent decision about the logic sense of a bit (even in the presence of noise). the data recovery block provides the bit level to the main receiver shift register and also provides a noise flag status indica- tion. this block diagram is not detailed enough to show all of the subtleties of the rxd pin buffer logic; a complete schematic and explanation of this pin logic can be found in 7.3.6.1 pd0 (rxd) pin logic .
motorola asynchronous serial communications interface m68hc11 9-4 reference manual figure 9-2 sci receiver block diagram the heart of the receiver is the receive serial shift register shown in figure 9-2 . this fe nf or idle rdrf tc tdre scsr sci status 1 sbk rwu re te ilie rie tcie tie sccr2 sci control 2 wake m t8 r8 wakeup logic rie or ilie idle sci tx requests sci interrupt request internal data bus pin buffer and control ddd0 pd0 rxd scdr rx buffer stop (8)76543210 10 (11) - bit rx shift register (read only) sccr1 sci control 1 rie rdrf start msb all ones data recovery ? 16 rwu re m disable driver receiver baud rate clock 8 8 8
m68hc11 asynchronous serial communications interface motorola reference manual 9-5 shifter is enabled by the receive enable (re) bit from the sci control register 2 (sccr2). the m bit from the sccr1 register determines whether the shifter will be 10 or 11 bits long. after detecting the stop bit of a character, the received data is trans- ferred from the shifter to the scdr, and the receive data register full (rdrf) status flag is set. when a character is ready to be transferred to the receive buffer but the previous character has not yet been read, an overrun condition occurs. in the overrun condition, data is not transferred and the overrun (or) status flag is set to indicate the error. the wake-up block uses the wake control bit from sccr1 to decide whether to use the most significant bit (msb) signal (address mark) or the all ones signal (idle line) to wake up the receiver. when the selected condition is detected, the wake-up logic clears the receiver wake-up (rwu) bit in sccr2, which wakes up the receiver. there are three receiver-related interrupt sources in the sci. these flags can be polled by software or optionally cause an sci interrupt request. the receive interrupt enable (rie) control bit enables the rdrf and the or status flags to generate hard- ware interrupt requests. the idle line interrupt enable (ilie) control bit allows the idle status flag to generate sci interrupt requests. 9.2 sci registers and control bits primarily, the sci system is configured and controlled by five registers (baud, sccr1, sccr2, scsr, and scdr). in addition, the port d register, data direction register for port d (ddrd), and the port d wired-or mode bit in the spi control regis- ter (spcr) are secondarily related to the sci system. first, the main function of each of these registers is presented, and then detailed descriptions of each bit are present- ed. when the sci receiver and/or transmitter is enabled, the sci logic takes control of the pin buffers for the associated port d pin(s). data directions for the rxd and txd pins are overridden to input and output, respectively. even though it does not control the direction of port d pins while the sci has control, the ddrd can be important to a user because it influences what will be read when port d is read by software. the ddrd also determines how the pin will behave when the sci gives up control. the port d register is important to an sci user because the value written to port d can determine what will be driven out of port d when the sci gives up control. the port d wired-or mode bit in the spcr modifies the driver functions of port d pins, even if they are being used for sci or spi functions. the baud-rate control register (baud) is used to select the baud rate for sci opera- tions and contains two control bits for factory testing. sccr1 includes three bits associated with the optional 9-bit data format. the wake bit is used to select one of two methods of receiver wake up. sccr2 contains the main sci controls. the upper four bits are local interrupt enable controls, which determine whether sci status flags will be polled or will generate hard- ware interrupt requests. the te and re bits are the respective transmitter and receiv-
motorola asynchronous serial communications interface m68hc11 9-6 reference manual er subsystem enable controls. the rwu bit allows software to put the receiver to sleep and hardware to automatically wake it up by clearing this bit. the send break sbk bit allows software to generate break characters on the txd line. the scsr contains two transmitter status flags and five receiver-related status flags. the transmitter generates flags for tdre and tc. the receiver generates flags for rdrf, or, idle-line detect (idle), a noise flag (nf), and a framing error (fe) indica- tion. the scdr is actually two separate registers. tdr is a write-only transmit data buffer register, and rdr is a read-only receive data buffer register. when software reads scdr, it is accessing rdr; when software writes to scdr, it is accessing tdr. 9.2.1 port d related registers and control bits (portd, ddrd, spcr) the following registers are the port d related registers. because the sci system uses the two lsbs of this port, only the interactions between general-purpose i/o and the use of these pins by the sci will be discussed. the actual mos logic for port d pins is shown and discussed in 7.3.6 port d . each internal peripheral subsystem interacts with port i/o pins in different ways. in some cases, such as the sci system, the internal subsystem overrides other pin con- trols to actively take charge of the pin. in other cases, such as the spi and pulse ac- cumulator, the pin controls (data direction and others) still influence the configuration of the pin logic. the user must never assume that all pins in a port are affected in the same way by data direction controls. when the sci receiver is enabled (by the re bit in the sccr2 register), bit 0 of ddrd is overridden, and the output buffer is disabled. writes to port d bit 0 while the sci has control of the pin do not alter the logic state at the pin; however, any value written is remembered in an internal latch. if the sci receiver later relinquishes control of the pin, the logic value in this latch will drive the pd0/rxd pin. although the ddrd0 bit does not affect the pin while the sci receiver is enabled, it still affects what is returned when port d is read. if ddrd0 is zero, the pin is read. if ddrd0 is one (suggesting the pin should be an output), the value in the internal port d bit 0 latch is returned. bit 7 6 5 4 3 2 1 bit 0 reset: 0 0 0 0 0 0 0 0 refer- ence: pd5/ ss pd4/sck pd3/ mosi pd2/ miso pd1/txd pd0/rxd $1009 0 0 ddrd5 ddrd4 ddrd3 ddrd2 ddrd1 ddrd0 ddrd reset: 0 0 0 0 0 0 0 0 $1028 spie spe dwom mstr cpol cpha spr1 spr0 spcr reset: 0 0 0 0 0 1 u u
m68hc11 asynchronous serial communications interface motorola reference manual 9-7 when the sci transmitter is active, bit 1 of ddrd is overridden, and the corresponding output buffer is forced on and is driven by sci logic (as opposed to port output logic). the transmitter is active (controlling the pd1/txd pin) whenever the transmitter en- able bit (te in the sccr2 register) is one or an unfinished character is being transmit- ted after the te bit is disabled. writes to bit 1 of port d while the sci has control of the pin do not alter the logic state at the pin; however, any value written is remembered in an internal latch. if the sci transmitter later relinquishes control of the pin, the logic value in this latch will drive the pd1/txd pin. although the ddrd1 bit does not affect the pin while the sci transmitter is active, it still affects what is returned when port d is read. if ddrd1 is zero, the pin is read (reflects what the sci transmitter is currently driving out of the pin). if ddrd1 is one (suggesting the pin should be an output), the value in the internal port d bit 1 latch is returned (reflects what the pin would revert to if the sci transmitter relinquishes control of the pin). all six bits of port d are affected by the port d wired-or mode control bit (dwom in the spcr). whenever dwom is one, the high-side driver (p-channel device) for all port d pins is disabled. this disabling makes port d pins behave somewhat like open- collector outputs; thus, an external pull-up resistor is needed for any port d pin being used as an output (general-purpose or peripheral subsystem outputs). the dwom bit does not affect the use of port d pins as inputs. 9.2.2 baud-rate control register (baud) the following register and paragraphs describe the baud control register, which is used to set the bit rate for the sci system. normally, this register is written once during initialization to set the baud rate for sci communications. both the receiver and the transmitter use the same baud rate, which is derived from the mcu bus rate clock. a two-stage divider is used to develop customary baud rates from normal mcu crystal frequencies; therefore, it is not necessary to use special baud-rate crystal frequencies. table 9-1 and table 9-2 should be adequate for most users, but a more comprehen- sive tabulation of baud rates is provided in table 9-3 to help users with unusual re- quirements. tclr clear baud-rate timing chain (test modes only) this bit is disabled and remains low in any mode other than test or bootstrap modes. reset clears this bit. while in test or bootstrap modes, writing a one to this bit causes the baud-rate counter chains to be reset. because the one state of this bit is transitory, reads always return a logic zero. this control bit is intended only for factory testing of the mcu. scp[1:0] sci baud-rate prescale selects these two bits select a prescale factor for the sci baud-rate generator. the output fre- quency of this prescaler determines the highest available baud rate in the system. the baud baud rate control register $102d bit 7 654321 bit 0 tclr 0 scp1 scp0 rckb scr2 scr1 scr0 reset: 00000uuu
motorola asynchronous serial communications interface m68hc11 9-8 reference manual actual 16 x baud rate will be a binary submultiple ( ? 1, ? 2, ? 4,... ? 128) of this pres- caler output as selected by the scr[2:0] bits. table 9-1 shows the highest baud rates that result for various combinations of crystal frequency and prescaler select control bit values. the actual frequency coming out of this prescaler stage is 16 times the baud rates listed. since not all of these entries are of practical use, the ones of interest have been highlighted in bold. this prescaler is set to its fastest rate by default out of reset and may be changed at any time. of course, it makes no sense to change the baud rate while any sci transfer is in progress. rckb sci baud-rate clock test (test modes only) this bit is disabled and remains low in any mode other than test or bootstrap modes. reset clears this bit. while in test or bootstrap modes, this bit may be written but not read (reads always return a logic zero). writing a one to this bit enables a baud-rate counter test mode where the exclusive-or of the receiver clock (16 x the baud rate) and the transmit clock (1 x the baud rate) is driven out the pd1/txd pin. this control bit is intended only for factory testing of the mcu. scr[2:0] sci baud-rate selects these three bits are used in conjunction with the sci prescaler bits (see table 9-1 )to specify the sci baud rate. the prescale bits, scp[1:0], determine the highest baud rate; whereas, the scr[2:0] bits select an additional binary submultiple ( ? 1, ? 2, ? 4, ... ? 128) of this highest baud rate. the result of these two dividers working in series is the 16 x receiver baud-rate clock. table 9-2 shows the sci baud rates that result for various settings of scr[2:0] and the highest baud rates from table 9-1 . since not all of these entries are of practical use, the ones of interest have been highlighted in bold. the scr[2:0] bits are not affected by reset and may be changed at any time. of course, it makes no sense to change the baud rate while any sci transfer is in progress. table 9-1 baud-rate prescale selects scp1 scp0 division factor crystal frequency 2 23 hz 8 mhz 4.9152 mhz 4 mhz 3.6864 mh highest baud rate 0 0 1 131.072k baud 125.000k baud 76.80k baud 62.50k baud 57.60k baud 0 1 3 43.691k baud 41.667k baud 25.60k baud 20.833k baud 19.20k baud 1 0 4 32.768k baud 31.250k baud 19.20k baud 15.625k baud 14.40k baud 1 1 13 10.082k baud 9600 baud 5.908k baud 4800 baud 4431k baud 2.1 mhz 2 mhz 1.2288 mhz 1 mhz 921.6 khz bus frequency (e clock)
m68hc11 asynchronous serial communications interface motorola reference manual 9-9 9.2.3 sci control register 1 (sccr1) the sccr1 contains control bits relate to the 9-bit data character format and the re- ceiver wake-up feature. four of the bits in this register are not used and always read as zeros. r8 receive data bit 8 when the sci system is configured for 9-bit data characters, this bit acts as an extra (ninth) bit of the rdr. the msb of received characters is transferred into this bit at the same time the remaining eight bits are transferred from the serial receive shifter to the scdr. t8 transmit data bit 8 when the sci system is configured for 9-bit data characters, this bit acts as the extra (ninth) bit of the tdr. when the low-order eight bits of a transmit character are trans- ferred from the scdr to the serial transmit shift register, this bit is transferred to the ninth bit position of the shifter. in cases where the sense of this bit is the same as it was for the previous character, it is not necessary to write to this bit before transmis- sion of the new character. for example, if the 9-bit format is used to get an extra stop bit (logic one), the t8 bit is written to one before transmitting the first character, and no other writes are needed. m sci character length 0 = one start bit, eight data bits, one stop bit 1 = one start bit, nine data bits, one stop bit the m bit controls the character length for both the transmitter and receiver at the same time. the 9-bit data format is most commonly used for an extra stop bit or in con- junction with the address-mark wake-up method, but it can also be used for parity. table 9-2 baud-rate selects scr 2 scr 1 scr 0 divi- sion factor highest baud rate (from table 9-1 ) 131.072k baud 32.768k baud 76.80k baud 19.20k baud 9600 baud sci baud rate 0 0 0 1 131.072k baud 32.768k baud 76.80k baud 19.20k baud 9600 baud 0 0 1 2 65.536k baud 16.384k baud 38.40k baud 9600 baud 4800 baud 0 1 0 4 32.768k baud 8192 baud 19.20k baud 4800 baud 2400 baud 0 1 1 8 16.384k baud 4096 baud 9600 baud 2400 baud 1200 baud 1 0 0 16 8192 baud 2048 baud 4800 baud 1200 baud 600 baud 1 0 1 32 4096 baud 1024 baud 2400 baud 600 baud 300 baud 1 1 0 64 2048 baud 512 baud 1200 baud 300 baud 150 baud 1 1 1 128 1024 baud 256 baud 600 baud 150 baud 75 baud sccr1 sci control register 1 $102c bit 7 654321 bit 0 r8 t8 0 m wake 0 0 0 reset: u u 000000
motorola asynchronous serial communications interface m68hc11 9-10 reference manual mark and space parity are trivial, but odd and even parity require software calcula- tions. wake wake-up method select 0 = idle line; detection of at least a full character time of idle line causes the receiver to wake up. 1 = address mark; a logic one in the msb position (eighth or ninth data bit depend- ing on character size selected by m bit) causes the receiver to wake up. 9.2.4 sci control register 2 (sccr2) the sccr2 is the main control register for the sci subsystem. tie transmit interrupt enable 0 = tdre interrupts disabled (software polling mode). 1 = an sci interrupt is requested when tdre is set to one. tcie transmit complete interrupt enable 0 = tc interrupts disabled (software polling mode). 1 = an sci interrupt is requested when tc is set to one. rie receive interrupt enable 0 = rdrf and or interrupts disabled (software polling mode). 1 = an sci interrupt is requested when either rdrf or or is set to one. ilie idle-line interrupt enable 0 = idle interrupts disabled (software polling mode). 1 = an sci interrupt is requested when idle is set to one. the idle-line function is inhibited while the receiver wake-up function is enabled. te transmit enable 0 = sci transmitter disabled 1 = sci transmitter enabled the transmitter does not turn off in the middle of a character. when te is written to zero, the transmitter keeps control of the txd pin until any character in progress (in- cluding preambles or break characters) is finished. when te is written from zero to one, the transmitter sends a preamble character consisting of 10 (11 if m = 1) bits of logic one. this mechanism can be used to queue an idle character time between the last character of one message and the first character of the succeeding message. the procedure would be to wait for tdre to be set after writing the last character to the scdr (this signals that the character has transferred to the shifter to be sent serially). then write te to zero and back to one. since the last character is still being shifted out, the transmitter will not relinquish control of the txd pin, but the act of writing te from zero to one causes an idle preamble character to be queued to be sent as soon sccr2 sci control register 2 $102d bit 7 654321 bit 0 tie tcie rie ilie te re rwu sbk reset: 00000000
m68hc11 asynchronous serial communications interface motorola reference manual 9-11 as the last character from the previous message finishes being shifted out. finally, write the first character of the next message to the scdr. this new character will start transmitting as soon as the queued idle character finishes. re receive enable 0 = sci receiver disabled 1 = sci receiver enabled while the sci receiver is disabled, the rdrf, idle, or, nf, and fe status flags can- not become set. if these flags were set, turning off re does not cause them to be cleared. rwu receiver wake up 0 = normal sci receiver operation (wake-up feature not enabled). 1 = places the sci receiver in a standby mode where receiver-related interrupts are inhibited until some hardware condition is met to wake up the sleeping re- ceiver. the condition that wakes the receiver up depends on which method of wake up was specified with the wake bit in sccr1. although it is possible for software to write the rwu bit to zero, is very unusual to do so. the normal sequence is for software to set the rwu bit after deciding that a par- ticular sci message is of no interest. setting the rwu bit causes the receiver to go to sleep (ignore further receiver interrupt sources) until the start of the next message. re- ceiver wake-up logic recognizes when the unimportant message is over and automat- ically clears the rwu bit to wake up the sleeping receiver. sbk send break 0 = normal transmitter operation. 1 = enable transmitter to send synchronous break characters. whenever the sbk bit is written to one, at least one character time of break will be queued and sent. in the context of the m68hc11, a break character causes the txd line to go to logic zero for 10 (11 if m = 1) bit times. in old teletype systems, a break was caused by simply disconnecting the serial line, which caused the line to go to logic zero for some asynchronous length of time (usually as long as the break key was pressed). a receiver seeing a break character produced by an m68hc11 would receive an all-zero character with a framing error (fe) because the line would be low where the receiver expected to see a logic-high stop bit. the break characters in the m68hc11 are synchronous because no partial character times of the break condition are ever produced. when sbk is set to one, a break char- acter is queued pending completion of any character currently shifting out of the trans- mit shift register. when the transmit shift register becomes available, the queued break character is jammed into the shift register to be serially sent, and, if the sbk bit is still one, another break is queued. it will always be at least one character time from when the sbk bit is written back to zero before the transmitter can resume sending normal characters. 9.2.5 sci status register (scsr) the seven status bits associated with the sci system are located in the scsr, which is depicted in the following register. some of these bits optionally generate hardware
motorola asynchronous serial communications interface m68hc11 9-12 reference manual interrupt requests; whereas, others simply indicate errors in the reception of a charac- ter. these status bits are automatically set by the corresponding conditions having been met in the sci logic. once set, these bits remain set until software completes a clearing sequence. the clearing sequences are somewhat automatic in that they are satisfied by performing functions normally done anyway. for example, to clear the tdre flag, software must read the scsr while tdre is set, and then write to the tdr. since these are exactly the normal steps in response to the tdre, no instruc- tions are needed to clear the flag. tdre transmit data register empty 0 = not empty; a character was previously written to the scdr and has not yet transferred to the transmit shift register to be serially sent. 1 = indicates a new character may now be written to the scdr. in normal transmit operations, this bit is checked before each new character is sent to see if the scdr can accept the new data. the sci transmitter is double buffered so the tdr holds the second character in line while the transmit serial shift register holds the character in the process of being transmitted serially. the tdre flag is cleared by reading scsr, followed by a write to the scdr. tdre must be read as one during the read of scsr, or the first step of the clearing sequence is not satisfied. the tdre bit is set to one during reset to indicate that there is no meaningful data in the scdr. tc transmit complete 0 = the transmitter is busy sending a character, preamble, or break character. 1 = the transmitter has completed sending and has reached an idle state. this bit is useful in systems where the sci is driving a modem. when tc is set at the end of a transmission, the modem can be disabled. in older acia and sci systems, the tdre status bit was the only indication that a transmission was near completion. since tdre only indicated that the last character had transferred to the transmit shift register, software had to delay an amount of time greater than or equal to the time it took for this last character to finish transmitting serially. since the delay time depended on the baud rate, it was relatively difficult to know when it was safe to disable the mo- dem. the tc bit on the m68hc11 offers a much more convenient way to tell when the transmitter has completed sending. the tc flag is cleared by reading scsr, followed by a write to the scdr. tc must be read as one during the read of scsr, or the first step of the clearing sequence is not satisfied. the tc bit is set to one during reset to indicate that the transmitter is not busy transmitting anything. rdrf receive data register full 0 = not full; nothing has been received since the last character was read out of the scdr. 1 = a character has been received and has transferred from the receive shift reg- ister to the parallel scdr where software can read it. scsr sci status register $102e bit 7 654321 bit 0 tdre tc rdrf idle or nf fe 0 reset: 11000000
m68hc11 asynchronous serial communications interface motorola reference manual 9-13 this is the normal indication that a character has been received by the sci. the nf and fe status bits provide additional information about this normally received charac- ter in the scdr. if set, the or flag would indicate that another character was serially received and was ready to be transferred to the scdr, but the previously received character was not yet read. software should check rdrf, or, nf, and fe to tell if there was any error in the reception of a character (rdrf should be set and the other three flags should be clear). the rdrf flag is cleared by reading scsr, followed by a read of the scdr. rdrf must be read as one during the read of scsr, or the first step of the clearing sequence is not satisfied. since the nf and fe flags are set at the same time as rdrf, the clearing sequence for rdrf will also clear nf and fe if they were set for this received character. idle idle-line detect 0 = the rxd line is either active now or has never been active since idle was last cleared. 1 = the rxd line has become idle. the idle condition is defined as at least a full character time of logic one on the rxd line. a character time is 10 bit times if m = 0 or 11 bit times i fm=1.the idle flag is cleared by reading scsr, followed by a read of the scdr. idle must be read as one during the read of scsr, or the first step of the clearing sequence is not satisfied. once idle has been cleared, it cannot be set again until the rxd line has been active and then becomes idle again. the idle-line function is inhibited while the receiver wake-up function is enabled (rwu = 1). or overrun error 0 = no overrun error. 1 = indicates that another character was serially received and was ready to be transferred to the scdr, but the previously received character was not yet read. since the sci receiver is double buffered, there is a full character time between recep- tion of a character and when it must be read from the scdr to avoid an or caused by a subsequent character. in an or condition, the character that caused the or is lost, but the previously received character in the scdr is not disturbed. the nf and fe status bits are associated with the normally received character in the scdr (never the character that caused an or). the or flag is cleared by reading scsr, followed by a read of the scdr. or must be read as one during the read of scsr, or the first step of the clearing sequence is not satisfied. nf noise flag 0 = no noise detected during reception of the character in the scdr. 1 = data recovery logic detected noise during reception of the character in the scdr. nf does not generate interrupt requests because it is always associated with the set- ting of rdrf, which does cause interrupts. even if the noise is detected early in the reception of the character, nf is not set until rdrf is set at the end of reception of a character. perceived noise in any of the data bit times or the start or stop bit times will cause nf to be set. during data bit times and the stop bit time, noise is indicated if the three samples taken near the middle of the bit time do not unanimously agree. during
motorola asynchronous serial communications interface m68hc11 9-14 reference manual reception of the start bit, four additional samples are taken during the first half of the bit time to detect the leading edge of the bit time and to verify that it is a start bit. if all seven samples taken during the start bit time are not zero, noise is indicated and nf is set. many systems ignore the nf because the data recovery logic has already made a good first-order attempt to correct the problem. in critical applications, the nf could be used to generate a request for retransmission of the questionable data. the nf flag is cleared by reading scsr followed by a read of the scdr. nf must be read as one during the read of scsr, or the first step of the clearing sequence is not satisfied. fe framing error 0 = no framing error detected. 1 = a framing error was detected for the character in the scdr. asynchronous serial data reception requires the receiver to properly align the charac- ter reception frame with the incoming serial data. this alignment is achieved by asyn- chronously searching for the falling edge of the start bit; alignment is verified by looking for the expected logic high during the last bit time (stop bit) of the character. if a logic zero is detected where the stop bit was expected, the fe flag is set. the fe indicator is not a foolproof indication of improper framing. it is possible for the receiver to be mis- framed without there being any fe indication because the rxd line could by chance be high when the receiver expected to see the stop bit. the fe flag is cleared by reading scsr followed by a read of the scdr. fe must be read as one during the read of scsr, or the first step of the clearing sequence is not satisfied. 9.2.6 sci data register (scdr) the scdr shown in the following register is actually two separate registers. when scdr is read, the read-only rdr is accessed; when scdr is written, the write-only tdr is accessed. in discussions of the sci system, any of the mnemonics scdr, tdr, or rdr might be used to refer to this register location. 9.3 sci transmitter the sci transmitter (see figure 9-1 ) uses an internally generated bit-rate clock to se- rially shift data out of the txd pin. a normal transmission is initiated by enabling the transmitter (setting te to one) and then writing data to be transmitted to the scdr. since the sci transmitter is double buffered, a new character may be written to the transmit queue whenever the tdre status flag is set to one. the transmit bit-rate clock is free running, and there is normally no way to know where a bit clock transition will occur relative to the software instructions that write data to the tdr. since transfers to the transmit shift register and transmission of data must be scdr sci data register $102f bit 7 6 5 4 3 2 1 bit 0 r7 r6 r5 r4 r3 r2 r1 r0 rdr (read) t7 t6 t5 t4 t3 t2 t1 t0 tdr (write) reset: u u u u u u u u
m68hc11 asynchronous serial communications interface motorola reference manual 9-15 synchronized to this bit-rate clock, there will be an uncertainty about exactly when a character will start being transmitted relative to when it was written to the tdr. the transmit bit-rate clock is free running as opposed to being started when a character is written to the tdr. transmitter logic adds a zero start bit and a one stop bit to the data characters pre- sented by the cpu for transmission. the transmitter can be configured to send char- acters with eight (m = 0) or nine (m = 1) data bits. when the tdr is able to accept a new data character, the tdre status flag is set, and an interrupt can optionally be gen- erated. another status flag (tc) and optional interrupt are produced when the trans- mitter has finished sending everything in its queue. in addition to data characters, the transmitter is capable of sending idle-line characters and break characters, which are useful in multi-drop sci networks. the transmitter is double buffered, which means that one character can be in the parallel tdr while another is in the transmit shift reg- ister being sent. in the case of queued idle and break characters, three characters can be in the queue, but no more than two can be data characters. the last topic of dis- cussion for the transmitter will be the txd pin buffer. this flexible buffer can be used to control what happens to the txd pin when the transmitter is finished using the pin. 9.3.1 eight- and nine-bit data modes the m bit in the sccr1 determines the length of sci characters for both the transmit- ter and receiver. the most common configuration is one start bit, eight data bits, and one stop bit, which is selected by m equals zero. when m equals one, characters are composed of one start bit, nine data bits, and one stop bit. in this 9-bit data mode, the low-order eight bits come from the normal tdr, and the ninth bit comes from the t8 bit of sccr1. data is transmitted lsb first, and this ninth bit becomes the new msb, which is transmitted just before the stop bit. since this bit is adjacent to the stop bit, it can be used as an extra stop bit by setting t8 to one. another common use for the 9-bit data format is in conjunction with the address-mark variation of receiver wake up. in a multi-drop sci network, all receivers evaluate the first characters of a message to decide whether or not this message is important to this receiver. if not, receiver wake up may be activated by writing a one to the rwu bit in sccr2. a one in rwu causes the receiver to ignore any other characters in the mes- sage, thus allowing the mcu to perform more useful functions than responding to in- terrupts from the sci. the sci receiver is still monitoring characters normally except that status flags and interrupts are not being produced. when address-mark wake up is being used, the sci receive logic automatically clears rwu when it sees a character whose msb is one. the one in the msb of a character indicates that this character is the first addressing character of a new message; thus, all receivers should wake up and evaluate this character. the 9-bit data format allows for full 8-bit data characters to be used in the body of a message while the ninth bit acts as the address marker. the first character of each message will have this ninth bit set to one; whereas, the remaining characters in the message will have a zero in this ninth bit. address-mark wake up can be used with 8-bit data format, but message characters could only use the lower seven bits for information. the ninth bit can also be used as a parity bit. mark or space parity can be produced
motorola asynchronous serial communications interface m68hc11 9-16 reference manual by simply making t8 equals one or t8 equals zero, respectively. odd and even parity require software calculations with the resulting parity-bit value stored in t8. a new t8 value will have to be calculated for each serial character. 9.3.2 interrupts and status flags two status flags are associated with the sci transmitter. these flags are read by soft- ware to tell when the corresponding condition exists. this technique is called polling. alternatively, a local interrupt enable bit can be set to enable each of these status con- ditions to generate interrupt requests when the corresponding condition is present. this technique is called an interrupt-driven operation. status flags are automatically set by hardware logic conditions, but software clears these flags, which provides an interlock mechanism for logic to know when software has noticed the status indication. the software clearing sequence for these status flags is automatic in that functions normally performed in response to the status flags also satisfy the conditions of the clearing sequence. when the transmitter is first enabled (te written to one), the tdre and tc flags are normally already set. the sci transmitter should be initialized in such a manner that the system can handle these interrupts before the te bit is written to one because an immediate interrupt can occur from these sources. the tdre flag indicates that there is room in the transmit queue to store another data character in the tdr. the tie bit is the local interrupt mask for tdre. when tie is zero, tdre must be polled; when tie is one, an interrupt is requested whenever tdre is one. to clear tdre, the user must read scsr while tdre is one, then write to scdr. the tc flag indicates that the transmitter has finished transmitting everything in its queue, including any idle preamble or break character that has been queued. the tcie bit is the local interrupt mask for tc. when tcie is zero, tc must be polled; when tcie is one, an interrupt is requested whenever tc is one. to clear tc, the user must read scsr while tc is one, then write to scdr. one interrupt vector is associated with the sci system; therefore, the interrupt service routine must begin by reading the scsr to determine which interrupt(s) caused the service routine to be called. possible interrupt sources include the two transmitter sources previously discussed and three receiver-related sources. 9.3.3 send break in the m68hc11, break characters are character-length periods where the txd line goes to zero. the character length for all characters, including idle and break charac- ters, is influenced by the m bit in sccr1. when m equals zero, all characters are 10 bit times long; when m equals one, all characters are 11 bit times long. break charac- ters have no start or stop bits. as long as the sbk control bit is one, break characters will be queued and sent. the txd line will continuously remain at zero while break characters are being sent. when sbk is written back to zero, at least one bit time of logic one will appear on the txd line as soon as the last break character is finished. this high bit time assures that a receiver can detect the falling edge at the beginning
m68hc11 asynchronous serial communications interface motorola reference manual 9-17 of the start bit for the next data character. if the transmitter is busy transmitting a character when sbk is toggled on and back off by software, exactly one break character will be produced following completion of the character that was being transmitted. if the transmitter is idle at the time the sbk bit is toggled on and off, it is not certain whether one or two break characters will be sent. when sbk is set to one, a break character is queued. when the transmit shift register becomes available and synchronization requirements are met with respect to the in- terna l 1 x baud-rate clock, the queued break character is jammed into the shift register to be serially sent and, if the sbk bit is still one, another break is queued. the transfer mechanism from the queue to the shifter is internally synchronized to the 1 x baud-rate clock; however, the relationship of this clock to operating software is not normally known. the instructions to write one and then write zero to the sbk bit execute very quickly relative to a normal baud-rate frequency, but there is still a small probability that the baud-rate clock edge could occur between writing the one and writing the zero to sbk. 9.3.4 queued idle character when the sci transmitter is not sending some character, it is idle and the txd line rests at logic one. this idle-line condition can last for essentially any length of time and should not be confused with idle characters. idle characters are character-length pe- riods where the txd line goes to logic one. the character length for all characters, in- cluding idle and break characters, is influenced by the m bit in sccr1. when m equals zero, all characters are 10 bit times long; when m equals one, all characters are 11 bit times long. idle characters have no start or stop bits. idle characters are only produced when the transmitter is enabled from a disabled state (te changed from zero to one). the first time the transmitter is enabled, this idle character acts as a preamble. the character-length period of logic one assures that any receiver connected to this transmitter will be resynchronized so that it can properly recognize the leading edge of the start bit for the next character. software can queue an idle character into a serial data stream by momentarily turning te off and then back on again. this queueing function is useful when using the idle- line variation of receiver wake up. in a multi-drop sci network, all receivers evaluate the first characters) of a message to decide whether or not this message is important to this receiver. if not, receiver wake up is invoked by writing a one to the rwu bit in sccr2. a one in rwu causes the receiver to ignore any other characters in the mes- sage, thus allowing the mcu to perform more useful functions than responding to in- terrupts from the sci. the sci receiver is still monitoring characters normally except that status flags and interrupts are not being produced. when idle-line wake up is be- ing used, the sci receive logic automatically clears rwu (waking up the receiver) when it sees a full character time of logic one. during a message, there must never be any gap between characters within a message because even a single bit time of idle can trigger wake up if the previous character was $ff. the queued idle function allows exactly one character time of idle to be inserted into the data steam to maintain max- imum efficiency and data throughput. before queued idle was available, software had to avoid writing to the tdr for two or more character times after seeing tdre go high,
motorola asynchronous serial communications interface m68hc11 9-18 reference manual which caused the txd line to go idle for enough time to trigger rwu. the new queued idle function is much cleaner and easier to use. the procedure for queueing an idle character is as follows. write the last character to the tdr and wait for tdre to become set (indicates the last character has transferred to the transmit shifter to be transmitted serially). write zero and then write one to te. since the last character is still being transmitted, the transmitter will not give up control of the txd pin, and the character being transmitted is undisturbed. the zero-to-one transition of te queues the idle character to be sent as soon as the transmit shifter becomes available. as soon as te is written back to one, the first character of the next message may be written to the tdr. in this unusual case, the transmit queue can be three characters deep: the last data character of the previous message still transmit- ting, the queued idle character, and the first character of the next message in the par- allel tdr. one subtle aspect of the txd pin buffer logic can be especially useful with the queued idle function. in the previous queued idle discussion, it was assumed that the transmit- ter would not relinquish control of the txd pin because the last character was still be- ing transmitted, but what if this character is completed while te is zero? this completion could occur if the user is using a fast baud rate and the system is so busy that there is a delay in responding to the tdre request. the txd pin will revert to the general-purpose i/o function. if this scenario is a possibility, write bit 1 of portd and ddrd to one. this configures the pd1/txd pin to behave as an output and drive a one if the transmitter relinquishes control of the pin. since this pin state is identical to an idle txd line, the system would see a slightly longer than expected idle character time. since the queuing of an idle character occurs at the rising edge of the te bit, exactly one idle character results from the queueing procedure. there is never any possibility of a second idle character being produced because of uncertainty about the relation- ship between the software and the internal baud-rate clock (as there was with queued break characters). 9.3.5 disabling the sci transmitter writing a zero to te requests that the transmitter stop when it can. the transmitter will finish any transmission in progress before actually shutting down. only an mcu reset can cause the transmitter to stop and shut down immediately. if te is written to zero when the transmitter is already idle, the pin will revert to its gen- eral-purpose i/o function (synchronized to the bit-rate clock). if anything is being trans- mitted when te is written to zero, that character is completed before the pin reverts to general-purpose i/o, but any other characters waiting in the transmit queue are lost. the tc and tdre flags are set at the completion of this last character even though te has been disabled. 9.3.6 txd pin buffer logic several features of the txd pin buffer logic are especially important to an sci user. when the sci transmitter is enabled, the data direction control is overridden, and the
m68hc11 asynchronous serial communications interface motorola reference manual 9-19 output buffer is forced on. when the transmitter is disabled and the transmission in progress is completed, the pin reverts to being a general-purpose i/o pin controlled by the portd and ddrd registers. in some systems, it is very important to know just what will happen to the pin when the sci stops controlling it. another feature of this pin buffer allows it to act like an open-collector-type buffer, which helps prevent other- wise catastrophic problems if two or more drivers connected to this same txd line were to become enabled at the same time. finally, the ddrd1 control bit still influenc- es what is returned on reads of portd even though it is overridden in terms of con- trolling the output buffer enable. figure 9-3 is a simplified block diagram of the txd pin logic that illustrates the points of the following discussion. the mos transistor-level schematic and a more detailed description of the txd pin logic are found in 7.3.6 port d . figure 9-3 txd pin logic block diagram output buffer [1] is enabled by ddrd or by the sci transmitter on (xmiton) signal. the xmiton signal is active while the te bit is one and long enough after te is written to zero to allow any currently transmitting character to finish. the dwom signal deter- mines whether port d pins will act as open-collector-type drivers or as totem-pole-type drivers. dwom simultaneously controls all six port d pins; thus, if open-collector-type operation is needed on any port d pin(s), it must be used on all six. a fairly common case might be where the spi needed open-collector operation so dwom is set to one. in this case, the txd pin needs a pull-up resistor since the internal high-side driver was disabled. the data driven out the txd pin is selected by multiplexer [2]. when the transmitter is enabled, sci transmit data will drive the pin buffer. when the transmitter is disabled, d c q q hff output buffer dwom pd1 txd mux a b a/b mux a b a/b input buffer [2] [4] [6] [1] [3] xmiton wportd ddrd1 internal data bus rportd sci transmit data enable open drain/totem [5]
motorola asynchronous serial communications interface m68hc11 9-20 reference manual latched port d data from half flip-flop (hff) [3] drives the pin buffer. hff [3] holds the last data written to portd even if the transmitter was enabled at the time. the ddrd1 control bit provides an enable for pin output buffer [1] and a select to mul- tiplexer [4]. when portd is read, analog switch [5] couples the output of multiplexer [4] onto the data bus to the cpu. multiplexer [4] determines what will be returned on reads of port d. if ddrd1 is one, the output of the port d bit 1 latch [3] is read. if ddrd1 is zero, pin input buffer [6] is read. when the sci transmitter is enabled, set- ting ddrd1 to zero allows software to directly read the current state of the txd pin as data is being serially transmitted. in unusual cases, port d bit 1 latch [3] can be used as a software flag bit that can be written and read without disturbing sci transmis- sions. probably the most commonly used aspect of the txd pin logic is the ability to control what the pin does after the sci gives up control. for the pin to revert to a driven high, write ddrd1 and port d bit 1 to ones. for the pin to revert to high impedance, write a zero to ddrd1. this high-impedance choice is useful in multidrop systems where more than one transmitter is connected to a common transmit line but no more than one transmitter is ever simultaneously using the line. the high-impedance choice can also be used to make a two-wire sci system where the txd and rxd pins of the m68hc11 are tied together and data travels in only one direction at a time (half du- plex). since the m68hc11 is a cmos device, it is a good idea to select the wired-or option with dwom whenever more than one output driver could potentially try to drive the same line. 9.4 sci receiver the sci receiver is responsible for synchronization to the serial data stream and re- covery of data characters. since the data stream has no clock, data recovery depends on the transmitting device and the receiving device operating at close to the same baud rate. the sci system can tolerate a moderate amount of system noise without losing any information. the sci receive function is somewhat more difficult than the transmit function due to the asynchronous nature of incoming serial data. a significant amount of discussion will be devoted to the way the m68hc11 recognizes a start bit because this procedure determines the amount of baud-rate frequency mismatch that can be tolerated and gives an indication of how well this sci receiver can handle noise. second, basic dou- ble-buffered receive functions are discussed. finally, the two variations of the receiver wake-up function are explained. 9.4.1 data sampling technique the receiver front-end logic uses a sampling clock that is 16 times the baud-rate fre- quency. this sampling clock is called the rt clock in the following discussion, and one rt is understood to be one-sixteenth of a bit time. in the following figures, the rt clock cycles are numbered from one (start of a bit time) to 16 (end of a bit time).
m68hc11 asynchronous serial communications interface motorola reference manual 9-21 when the receiver is first enabled and after the reception of a stop bit at the end of a frame, an asynchronous search is initiated to find the leading edge of the next start bit. the goal of this asynchronous search is to gain bit-time synchronization between the serial data stream and the internal rt clock. once synchronization has been estab- lished, the rt clock controls where the mcu perceives the bit-time boundaries to be. the first step in locating a start bit is to find a sample where rxd is zero preceded by three consecutive samples of logic one. these four samples are called start-bit quali- fiers. until the start-bit qualifiers are detected, the rt clock is reset to state rt1 after each sample. once the qualifiers are found, the beginning of a start bit is tentatively assumed, and subsequent samples are assigned successive rt state numbers. next, start-bit verification samples are taken at rt3, rt5, and rt7. if any two of the three verification samples are logic ones, the low at rt1 is assumed to have been noise, and the asynchronous search is started again. when the start-bit qualifiers and the start-bit verification requirements are met, synchronization has been achieved, and the rt count state is used to determine the position of bit-time boundaries. during each bit time, including the start and stop, data samples are taken at rt8, rt9, and rt10 to determine the logic sense of the bit time and to (possibly) set a working nf. the logic sense of the bit time is considered to be the majority of all samples taken during the bit time. if any sample disagrees with the rest, the working nf is set. even if the samples at rt8, rt9, and rt10 suggest it should be one, the start bit time is always assumed to be zero. the primary reason for this assumption is to avoid an ac- cidental wake up while using the idle-line variation of receiver wake up. if the previous character had been all ones ($ff), the stop bit and the erroneous logic high in the new start bit would combine to make a full character time of logic one and would errone- ously wake up the receiver. also, at least three of the four samples at rt1, rt3, rt5, and rt7 were logic zero, which would contradict a decision of logic one based on the samples at rt8, rt9, and rt10. if there is any disagreement among the samples taken during any bit time in a frame (including the start and stop), the working nf is set. at the end of a character recep- tion, data is transferred from the receive shifter to the parallel rdr, and the rdrf flag is set. if noise was detected during reception of the character, the nf is set at the same time as rdrf. figure 9-4 shows the details of the ideal case of start-bit recognition. all samples tak- en at [1] detect logic ones on the rxd line and correspond to the idle-line time or a stop-bit time prior to this start bit. at [2] a logic-zero sample is preceded by three logic- one samples. these four samples are called the start-bit qualifiers. the beginning of the start bit time is tentatively perceived to occur between the third logic-one sample and the logic-zero sample of the start qualifiers. next, the samples at rt3, rt5, and rt7 [3] are taken to verify that this bit time is indeed the start bit. the samples at rt8, rt9, and rt10 are called the data samples [4]. in any bit time other than the start bit, these samples would drive a majority voting circuit to determine the logic sense of the bit time. in the special case of the start bit time, the bit value is forced to be zero inde- pendent of what the data samples at rt8, rt9, and rt10 suggest.
motorola asynchronous serial communications interface m68hc11 9-22 reference manual figure 9-4 start bit ideal case in this ideal case, the actual start bit and the perceived start bit match. the resolution of the rt clock leads to an uncertainty about the exact placement of the leading edge of the start bit. the uncertainty in the placement of the edge will be one-sixteenth of a bit time. figure 9-5 shows what occurs if noise causes a sample to be erroneously detected as a zero before the actual beginning of the start bit. logic-zero sample [1] in conjunc- tion with the three preceding samples of logic one meet the conditions for start quali- fication; thus, logic tentatively perceives the start bit as beginning here. subsequent start-verification samples at rt3 and rt5 [2] are both ones; therefore, the tentative placement of the start edge is rejected, and the search is restarted. when the sample at the actual beginning of the start bit is detected, the preceding three samples are ones; the start bit is now perceived to begin here. in this case, the three samples taken at rt3, rt5, and rt7 now verify that the start bit has been found. figure 9-5 start bit noise case one figure 9-6 is similar to the previous case except noise [1] is now closer to the actual beginning of the start bit. the noise sample and the preceding three ones meet the rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 rt2 rt3 [1] [2] [3] [4] 0 10 10 11 0 11 0 10 10 1 actual start bit perceived start bit lsb rt4 rxd pin samples rt clock (16x baud rate) rt clock state reset rt rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 rt2 rt3 0 10 10 10 0 10 10 10 1 actual start bit perceived start bit lsb rt4 rxd pin samples rt clock (16x baud rate) rt clock state reset rt [2] [1]
m68hc11 asynchronous serial communications interface motorola reference manual 9-23 start qualification requirements. the start-verification sample at rt3 [2] is one, which will cause the working nf to be set. the samples at rt5 and rt7 [3] are zeros. since two out of three of the start-verification samples are correct, the original perceived po- sition for the beginning of the start bit is accepted. the rt clock will roll over from state 16 to state 1 [4], and bit-time misalignment [5] will continue for the remainder of this character. (a one-to-zero transition in the data character would cause the alignment to be readjusted.) even though the perceived alignment of the serial data to the rt clock is technically incorrect, the data samples at rt8, rt9, and rt10 fall well within the actual bit time. this character would almost certainly be received correctly; how- ever, the nf will be set to inform the user of the questionable character. figure 9-6 start bit noise case two figure 9-7 shows a burst of noise [1] causing two samples to detect erroneous zeros. the sample at rt5 would cause the working nf to set. even though this example shows a worst-case alignment of perceived bit-time boundaries to actual bit-time boundaries, the data samples taken at rt8, rt9, and rt10 will fall within the actual bit time, and data recovery should still be successful. perceived bit-time boundary [2] is almost half a bit time too soon; however, the data samples for lsb [3] still fall within the actual lsb bit time. this example is a theoretical case, and such gross noise should never be seen in an actual application. this case is an indication of how toler- ant the sci receiver is to system noise. rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt5 rt6 rt7 rt8 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 rt2 rt3 0 10 10 10 0 11 0 1 actual start bit perceived start bit lsb rt4 rxd pin samples rt clock (16x baud rate) rt clock state reset rt [2] [1] [3] [4] perceived lsb [5]
motorola asynchronous serial communications interface m68hc11 9-24 reference manual figure 9-7 start bit noise case three figure 9-8 depicts the case of noise causing an erroneous sample of one early in the start bit. in this case, the nf would be set due to the one at sample rt3. the alignment of the perceived bit-time boundary matches that of the actual bit-time boundary. figure 9-8 start bit noise case four figure 9-9 shows a gross burst of noise [1] during the start-verification samples. the two logic-one samples at rt5 and rt7 cause the one-to-zero transition at the actual beginning of the start bit to be rejected as the perceived start bit. since there are no more cases of three logic-one samples in a row [2], the start bit is never detected. be- cause the circuit could not locate the start bit, the frame will be received as a framing error, be improperly received, or be missed entirely, depending on the data in the frame and when the start search logic synchronized on what it thought was a start bit. this example shows two independent noise incidents that are specifically positioned within a frame. of the six cases of noise during the start-bit search, this case is the only one that causes incorrect data reception. rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt5 rt6 rt7 rt8 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 rt2 rt3 0 10 10 10 010 actual start bit perceived start bit lsb rt4 rxd pin samples rt clock (16x baud rate) rt clock state reset rt [1] perceived lsb rt9 rt10 [2] [3] 00 0 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 rt2 rt3 0 10 11 10 10 10 10 1 actual start bit perceived start bit lsb rt4 rxd pin samples rt clock (16x baud rate) rt clock state reset rt 11 rt1 rt1 rt1 rt1
m68hc11 asynchronous serial communications interface motorola reference manual 9-25 figure 9-9 start bit noise case five the final start-bit case shown in figure 9-10 shows a burst of noise in the middle of the start bit time. the noise [1] causes two out of three data samples to be erroneously detected as ones. the start-bit logic forces this bit to be detected as a zero even though the majority of samples rt8, rt9, and rt10 suggest it should be one. the majority of all seven samples taken during the start bit time agree with the forced zero. another advanced feature of the data sampling technique allows the rt clock to be resynchronized on any valid one-to-zero transition in a frame. data is constantly being sampled and shifted into a 16 x baud-rate shift register. a one-to-zero transition is in- dicated by the pattern (1110d0d0d0), which corresponds to three logic-one samples preceding the falling edge and logic-zero samples at rt1, rt3, rt5, and rt7. (as long as no more than one of the samples at rt3, rt5, and rt7 was a one, the falling edge would be recognized.) this feature does not help a worst-case analysis. howev- er, this feature improves the probability of proper alignment between perceived bit times and actual bit times in the data stream, thus improving the reliability of normal data reception. figure 9-10 start bit noise case six after a framing error is detected (provided a break was not detected at the same time), rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 0 10 10 11 11 0 10 1 actual start bit no start bit foundsee text lsb rxd pin samples rt clock (16x baud rate) rt clock state reset rt 11 rt1 rt1 rt1 rt1 [2] [1] 1 0 0 0 0 0 0 d dd rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 rt2 rt3 0 11 11 10 10 10 10 1 actual start bit perceived start bit lsb rt4 rxd pin samples rt clock (16x baud rate) rt clock state reset rt 11 rt1 rt1 rt1 rt1 [1]
motorola asynchronous serial communications interface m68hc11 9-26 reference manual the three logic-one samples leading to start-bit qualification are forced into the high- speed shift register. this procedure is analogous to pretending the stop bit of the mis- framed character was really a logic one. the forced logic-one samples are positioned at rt14, rt15, and rt16 of the perceived stop bit in an attempt to permit normal re- ception to proceed. if the samples were not forced to ones, the subsequent start bit could be missed. a break is detected when a framing error occurs and the data char- acter associated with it is all zeros. in the case of a break detect, the artificial start edge is not forced. from an understanding of how character alignment is achieved and where the logic sense of a bit time is sampled, it is possible to calculate the worst-case baud-rate mis- match that can be tolerated between two sci devices. in this worst-case analysis, no one-to-zero transitions are assumed to occur within the character to cause realign- ment. the noise cases discussed previously are ignored because they do not apply to normal reception. in the case of baud-rate mismatch, the data sampling technique may be unable to recover correct data in the presence of gross noise. 9.4.2 worst-case baud-rate mismatch two cases must be considered and each of these cases must be modified for normal 8-bit data format and optional 9-bit data format. in the first case, a too-slow transmitting device sends characters to this sci receiver. in the second case, a too-fast transmit- ting device is operating above the ideal baud rate. when the accumulated bit-time alignment error causes more than one of the three data samples for the stop bit time to fall outside the actual stop bit time, an error has occurred. in both cases, assume the receiver is operating at the ideal baud rate for reference, which should provide the basis for any worst-case baud-rate analysis. for most users, the amount of mismatch that can be tolerated is much more than the amount that is ever likely to be encoun- tered. figure 9-11 (a) shows a worst-case slow signal on rxd relative to the rt clock states of the 16 x receiver rt clock. the alignment of the falling edge of start bit [1] in figure 9-11 (a) and [3] in figure 9-11 (b) shows the uncertainty resulting from the resolution of the rt clock. only two out of the three data samples for the stop bit fall within actual stop bit [2]. majority sampling can still correctly detect the stop-bit value of one, even if the msb had been a zero. of course, this worst-case analysis is not considering oth- er errors or noise.
m68hc11 asynchronous serial communications interface motorola reference manual 9-27 (a) receive data slower than receiver baud rate (b) receive data faster than receiver baud rate figure 9-11 baud-rate frequency tolerance for 8-bit data format, the ratio of the frequency of incoming data to the frequency of the receiver baud-rate clock can be written as follows: (9 bit times) ? [15/16 + 8(16/16) + 8/16] the nine bit times are measured from the leading edge of the start bit to the trailing edge of the msb (the stop bit was not measured although it could have been if a dif- ferent denominator time had been used). the 15/16 is the amount of overlap between the actual start bit and the perceived start bit. for convenience, multiply everything by 16 to obtain measurements in terms of rt clock cycles as opposed to baud-rate clock cycles. the 8(16/16) corresponds to the eight bit times of data between the perceived start and stop bits. the 8/16 corresponds to the portion of the perceived stop bit time to the boundary between the actual msb and stop bit. this ratio calculates as follows: (9 x 16)/(15 + 8 x 16 + 8) = 144/(15 + 128 + 8) = 144/151 = 95.36% the equivalent calculation for 9-bit data format would be (10 x 16)/(15 + 9 x 16 + 8) = 160/(15 + 144 + 8) = 160/167 = 95.81% figure 9-11 (b) can be used in a similar way to derive the calculations for the fastest serial data rate that can be tolerated. the actual start bit and the perceived start bit both begin at [3]. in this case, measure the time for the complete actual frame, which ends between rt clock states 9 and 10 of the perceived stop bit. the calculation for 8-bit data format is perceived start bit rxd pin 12345678910111213141516 12345678910 receiver rt clock state [2] stop msb start perceived stop bit [1] perceived start bit rxd pin 12345678910111213141516 12345678910 receiver rt clock state [4] stop idle or next character start perceived stop bit [3]
motorola asynchronous serial communications interface m68hc11 9-28 reference manual (10 x 16)/(9 x 16 + 9) = 160/153 = 104.56% the equivalent calculation for 9-bit data format is (11 x 16)/(10 x 16 + 9) = 176/169 = 104.14% for 8-bit data format, the baud-rate variation that can be tolerated is about 4.5%; for 9-bit data format, the variation is about 4%. this analysis assumes one of the devices was operating at the exact baud-rate frequency, and the calculations show how much the other device could vary from this. one device operating four percent too slow can- not communicate with another device operating four percent too fast. 9.4.3 double-buffered operation the sci receiver in the m68hc11 is double buffered, which means that the receiver can have up to two characters in it at any given moment. one of the characters is in a readable parallel receive data buffer (scdr); another could be shifting into the receive serial shift register. this double-buffered arrangement gives software some time to no- tice a received character and read it before the next serial character is finished. with- out double buffering, the transmitting device would be required to insert delays between transmitted characters to avoid a receiver overrun. an overrun occurs in a double-buffered m68hc11 if a serial character is received and is ready to transfer into the parallel rdr while there is still a previously received character in the rdr. the transfer could not occur without destroying the previously received character. 9.4.4 receive status flags and interrupts five status flags are associated with the sci receiver. rdrf is set and optionally gen- erates an interrupt request when a character has been received and transferred into the parallel rdr. the or flag is set and optionally generates an interrupt request in- stead of rdrf (if rdrf was already set when a new character was ready to be trans- ferred into the parallel rdr). when an overrun takes place, the new character is lost, and the character that was in its way in the parallel rdr is undisturbed. the nf and fe flags provide additional information about the character in the parallel rdr. since nf and fe are always accompanied by rdrf and since rdrf already generates an interrupt request, nf and fe do not. the last receiver status flag and interrupt source comes from the idle flag. the rxd line is idle if it has constantly been at logic one for a full character time. the idle flag is set only after the rxd line has been busy and becomes idle, which prevents repeated interrupts for the whole time rxd remains idle. status flags are set by the sci logic in response to specific conditions in the receiver. these flags can be read (polled) at any time by software. three of the flags (rdrf, or, and idle) can also optionally generate an automatic interrupt request. the rie is a local enable for both rdrf and or. if rie is set to one, rdrf and or generate interrupts whenever either is set to one. if rie is zero, rdrf and or do not generate interrupts, and the receiver operates in polled mode. ilie works similarly as a local en- able for the idle status flag. when ilie is set to one, an interrupt request is generated whenever idle is a one. when ilie is zero, the idle status flag does not generate interrupt requests. when the receiver wake-up function is enabled (rwu = 1), setting
m68hc11 asynchronous serial communications interface motorola reference manual 9-29 the idle flag is inhibited. 9.4.5 receiver wake-up operation the m68hc11 receiver logic hardware also supports a receiver wake-up function, which is intended for systems having more than one receiver. with this function, a transmitting device directs messages to an individual receiver or group of receivers by passing addressing information as the initial byte(s) of each message. receivers not addressed activate the receiver wake-up function, which makes these receivers dor- mant for the remainder of the unwanted message and eliminates any further software overhead to service the remaining characters of the unwanted message. the receiver is placed in wake-up mode by writing a one to the rwu bit in the sccr2 register. while rwu is one, all of the receiver-related status flags (rdrf, idle, or, nf, and fe) are inhibited (cannot become set). although rwu can be cleared by a software write to sccr2, to do so would be unusual. normally, rwu is set by soft- ware and is cleared automatically with hardware by one of the two following methods. 9.4.5.1 idle-line wake up to use this receiver wake-up method in an actual system, a software addressing scheme is established to allow the transmitting device(s) to direct messages to indi- vidual receivers or groups of receivers. this addressing scheme is purely a software device and may take any form as long as all transmitting and receiving devices are programmed to understand the same scheme. the addressing information is usually the first frame(s) in a message; therefore, uninterested receivers are burdened only with these minimum addressing frames. all receivers are awake (rwu = 0) when each message begins. as soon as a receiver determines that the message is not intended for it, software sets the rwu bit (rwu = 1), which inhibits further flag setting until the rxd line goes idle at the end of the message. as soon as an idle line is detected by receiver logic, hardware automatically clears the rwu bit so that the first frame of the next message can be received. this method of receiver wake up requires a minimum of one idle-line frame time between messages and no idle time between frames in a message. 9.4.5.2 address-mark wake up in this method of receiver wake up, all serial characters consist of seven (eight if m = 1) information bits and an msb, which is used to indicate an address character (when set to one (mark)). the first character of each message is an addressing character (msb is one). all receivers in the system evaluate this character to determine if the remainder of the message is directed toward this particular receiver. as soon as a re- ceiver determines that a message is not intended for it, the receiver activates the rwu function by setting (with a software write) the rwu bit. since setting rwu inhibits re- ceiver-related flags, there is no further software overhead for the rest of this message. when the next message begins, its first character will have its msb set, which auto- matically clears the rwu bit and enables normal character reception. the first char- acter whose msb is set will also be the first character to be received after wake up because rwu gets cleared before the stop bit for that frame is serially received. this
motorola asynchronous serial communications interface m68hc11 9-30 reference manual method of wake up allows messages to include gaps of idle time, unlike the earlier idle- line method, but there is an efficiency loss due to the extra bit time per character (ad- dress bit) required in all characters. 9.5 baud-rate generator this discussion, which provides a more detailed description of the baud-rate genera- tor, is useful to those users who have an odd crystal frequency or some other unusual requirement. the usual approach to selecting a baud rate is to start from a particular crystal frequency and select one of the 32 available division factors to arrive at a de- sired baud rate. if a system uses equipment from other manufacturers (such as a crt terminal or host computer), a standard baud rate, such as 9600 baud, is used. many applications include sci networks that do not have to communicate with ordinary rs232-type sources. in these cases, any frequency can be used as long as all of the devices in the network use the same baud rate for example, in the automotive in- dustry, 32.768k baud has commonly been used. these systems include separate controllers for various parts of the car and test equipment interfaces. all of the custom equipment is controlled by the automobile manufacturer. in this environment, high throughput on the sci and maximum bus frequency are more important than a cus- tomary baud rate. 9.5.1 timing chain block diagram figure 9-12 is a block diagram of the sci baud-rate timing chain. the crystal frequen- cy is divided by four to get the bus rate ph2 clock. ph2 is the same frequency as e (but leads e by 90 ). the prescale select bits, scp[1:0], select an initial division factor of 1, 3, 4, or 13 that drives a series of divide-by-two stages. the rate select bits (scr[2:0]) determine where the rt clock will be tapped off of this divider chain. the rt clock is 16 times the baud-rate frequency. this 16 x baud-rate clock is finally divid- ed by 16 to get the transmitter baud-rate clock. the actual baud-rate generator func- tions like this block diagram although the implementation is slightly different to overcome potential circuit-delay problems. (it is important to the overall sci circuit de- sign to maintain minimum delays from ph2 to baud rate clock edges.) 9.5.2 baud rates vs. crystal frequency table 9-3 is a complete listing of all possible baud rates that can be achieved for five crystal frequencies. the entries most likely to be of interest are in bold. 9.6 sci timing details the timing information presented in the following paragraphs is much more detailed than most users need but will help normal users better understand the sci system. for rare applications needing this much detail, this discussion is an authoritative ref- erence source although it is not intended to replace guaranteed data-sheet timing in- formation.
m68hc11 asynchronous serial communications interface motorola reference manual 9-31 figure 9-12 baud-rate generator block diagram 9.6.1 operation as transmitter is enabled when the transmitter is initially enabled (writing one to te), the sci logic overrides ddrd control of the pd1/txd pin, and an initial preamble character is sent. this pre- amble character is 10 (11 i fm=1)bit times of continuous logic high at the pin. an un- certainty arises because all transmissions are synchronized to the relatively slow baud-rate clock, and the relationship of this clock to running software is normally not known. figure 9-13 summarizes the timing details related to transmitter enable. ? 3 ? 4 ? 13 oscillator and clock generator ( ? 4) xtal extal e as internal bus clock (ph2) 1:1 scp[1:0] 1:0 0:1 0:0 ? 2 0:0:0 ? 2 0:0:1 ? 2 0:1:0 ? 2 0:1:1 ? 2 1:0:0 ? 2 1:0:1 ? 2 1:1:0 1:1:1 ? 16 sci receive baud rate (16x) scr[2:0] sci transmit baud rate (1x)
motorola asynchronous serial communications interface m68hc11 9-32 reference manual te can be written to one anytime in the interval from [1] to [3]; it will be recognized at the falling edge of tx clock [4]. the rising edge of te [1] is too late relative to the falling edge of internal tx clock [2]. the rising edge of te [3] is in time to be recognized at the falling edge of internal tx clock [4]. this reflects an uncertainty about the delay from writing te to one and when the sci transmitter actually takes control of the txd pin. the pin functions as the general-purpose i/o pin (pd1) until [5] where the sci table 9-3 baud rates by crystal frequency, scp[1:0] and scr[2:0] scp 1 scp 0 scr 2 scr 1 scr 0 crystal frequency 2 23 hz 8 mhz 4.9152 mhz 4 mhz 3.6864 mhz baud rates 0 0 0 0 1 65.536k baud 62.50k baud 38.40k baud 31.25k baud 28.80k baud 0 0 0 1 0 32.768k baud 31.25k baud 19.20k baud 15.625k baud 14.40k baud 0 0 0 1 1 16.384k baud 15.625k baud 9600 baud 7812.5 baud 7200 baud 0 0 1 0 0 8192 baud 7812.5 baud 4800 baud 3906 baud 3600 baud 0 0 1 0 1 4096 baud 3906 baud 2400 baud 1953 baud 1800 baud 0 0 1 1 0 2048 baud 1953 baud 1200 baud 977 baud 900 baud 0 0 1 1 1 1024 baud 977 baud 600 baud 488 baud 450 baud 0 1 0 0 0 43.691k baud 41.666k baud 25.60k baud 20.833k baud 19.20k baud 0 1 0 0 1 21.845k baud 20.833k baud 12.80k baud 10.417k baud 9600 baud 0 1 0 1 0 10.923k baud 10.417k baud 6400 baud 5208 baud 4800 baud 0 1 0 1 1 5461 baud 5208 baud 3200 baud 2604 baud 2400 baud 0 1 1 0 0 2731 baud 2604 baud 1600 baud 1302 baud 1200 baud 0 1 1 0 1 1365 baud 1302 baud 800 baud 651 baud 600 baud 0 1 1 1 0 683 baud 651 baud 400 baud 326 baud 300 baud 0 1 1 1 1 341 baud 326 baud 200 baud 163 baud 150 baud 1 0 0 0 0 32.768k baud 31.250k baud 19.20k baud 15.625k baud 14.40k baud 1 0 0 0 1 16.384k baud 15.625k baud 9600 baud 7812.5 baud 7200 baud 1 0 0 1 0 8192 baud 7812.5 baud 4800 baud 3906 baud 3600 baud 1 0 0 1 1 4096 baud 3906 baud 2400 baud 1953 baud 1800 baud 1 0 1 0 0 2048 baud 1953 baud 1200 baud 977 baud 900 baud 1 0 1 0 1 1024 baud 977 baud 600 baud 488 baud 450 baud 1 0 1 1 0 512 baud 488 baud 300 baud 244 baud 225 baud 1 0 1 1 1 256 baud 244 baud 150 baud 122 baud 112.5 baud 1 1 0 0 0 10.082k baud 9600 (+0.16%) 5908 baud 4800 (+0.16%) 4431 baud 1 1 0 0 1 5041 baud 4800 baud 2954 baud 2400 baud 2215 baud 1 1 0 1 0 2521 baud 2400 baud 1477 baud 1200 baud 1108 baud 1 1 0 1 1 1260 baud 1200 baud 738 baud 600 baud 554 baud 1 1 1 0 0 630 baud 600 baud 369 baud 300 baud 277 baud 1 1 1 0 1 315 baud 300 baud 185 baud 150 baud 138 baud 1 1 1 1 0 158 baud 150 baud 92 baud 75 baud 69 baud 1 1 1 1 1 79 baud 75 baud 46 baud 38 baud 35 baud 2.1 mhz 2 mhz 1.2288 mhz 1 mhz 921.6 khz bus frequency (e clock)
m68hc11 asynchronous serial communications interface motorola reference manual 9-33 transmitter takes over and begins sending the preamble character. figure 9-13 transmitter enable timing details 9.6.2 tdre and transfers from scdr to transmit shift register to transmit information, data is written to the scdr, which places data in the write- only tdr. this parallel buffer register holds the character until the transmit serial shift register is available. when any previously queued characters have finished, the data from the parallel tdr is transferred into the transmit shift register, and a start and stop bit are added to it. figure 9-14 shows the case where data was written to the scdr some time before the middle of the last bit time of a previous character. from this fig- ure and a functional understanding of the transmitter, a user could develop a similar timing diagram for cases where the transmitter is idle when scdr is written. a sequence of events begins at the middle of the last bit time of the previous character frame [1]. the inset of figure 9-14 shows an expanded view of this sequence. the rising edge of internal tx clock [2] occurs at a falling edge of the internal ph2 clock. at the next falling edge of ph2 [3], a one-half cycle transfer signal is generated. this in- ternal pulse causes the data waiting in the parallel tdr to be transferred into the trans- mit shift register. txd pin [5] finishes sending the stop bit from the previous character even though the next character is already in the transmit shift register to transmit im- mediately after the stop bit ends. at the next falling edge of ph2 [4], the tdre flag is set to indicate that the parallel tdr is available for another character. in a case where no data is waiting, in the parallel tdr, the tdre flag would already be one prior to [4]. no transfer pulse would be generated as there is nothing available to transfer. whenever data is finally written to the parallel tdr, it will transfer almost immediately to the shift register subject to synchronization delays. all transfers are synchronized to rising edges of the internal free-running tx clock signal. normally, the relationship between this internal baud-rate clock and running software is not known. synchronization uncertainty te tx clock [1] pin acts as pd1 general purpose i/o first bit time of preamble txd pin [3] [2] [4] [5]
motorola asynchronous serial communications interface m68hc11 9-34 reference manual figure 9-14 write scdr to serial data start 9.6.3 tc vs. character completion the last timing detail for the transmitter involves the end of a transmission. when the transmitter is disabled by writing te to zero, any character in progress finishes being transmitted before tc is set and the txd pin reverts to the pd1 general-purpose i/o function. figure 9-15 shows a case where te is cleared while a character is being transmitted. some time before completion of a transmit character, te is written to zero to disable the sci transmitter. the transmitter does not relinquish control of the pd1 pin until the end of the character that is in progress. at the end of stop bit [1] (the last bit time in the frame), tc is set, and the txd pin reverts to the pd1 general-purpose i/o function. the inset, an expanded view of the end of the stop bit, shows how these events are related to the ph2 clock. all bit-time boundaries are aligned to falling edges of the in- ternal tx clock. a falling edge of the tx clock occurs at a falling edge of the ph2 clock. transfer to tx shifter txd pin tx clock [1] stop bit [3] [2] [4] [5] tdre next start bit transfer to tx shifter txd pin ph2 tdre inset: expanded timing diagram.
m68hc11 asynchronous serial communications interface motorola reference manual 9-35 figure 9-15 ending details of transmission 9.6.4 rdrf flag setting vs. end of a received character a user is not generally concerned with timing relationships between an operating pro- gram and the serial receive data until a character has been completely received. after receiver logic detects the stop bit of a serial character, the character is transferred to the parallel rdr and the rdrf flag is set to one. figure 9-16 shows the details relat- ed to receive character completion. although the bit-time sampling is performed about the middle of a bit time, the rdrf flag is not set until the end of the perceived stop bit. small differences can exist be- tween the perceived and actual bit-time boundaries. the inset for figure 9-16 is ex- panded to show how the signals of interest relate to the relatively fast ph2 clock. in reality, bit times are not aligned with the falling edge of ph2, but perceived bit times are specifically aligned with the falling edge of ph2. the falling edge of ph2 [1] at the perceived end of the stop bit sets rdrf [2]. at the same time, a half-cycle transfer pulse is generated. this half-cycle active-low pulse [3] causes a received character to be transferred from the r x shifter to the parallel rdr. txd pin tx clock [1] stop bit tc txd pin tc ph2 inset: expanded timing diagram. pin reverts to pd1 function tx clock
motorola asynchronous serial communications interface m68hc11 9-36 reference manual figure 9-16 rdrf flag-setting details perceived rxd rdrf [1] perceived stop bit ph2 inset: expanded timing diagram. rdrf xfer [2] [3] xfer perceived end of stop bit
m68hc11 main timer and real-time interrupt motorola reference manual 10-1 section 10 main timer and real-time interrupt this section describes the main timer system of the MC68HC11a8. because the clocking chains associated with the real-time interrupt and computer operating prop- erly (cop) watch dog timer branch off the main timer counter, these timing functions are also discussed in this section. all major clock divider chains in the microcontroller unit (mcu) are illustrated from the oscillator to the serial baud-rate generators, which helps put the timer counter chain in context with the rest of the mcu system. since the architecture of the main timer is primarily a software-driven system, several application examples are included throughout this section. some examples demon- strate how to measure pulse widths and frequencies. other examples demonstrate techniques for controlling timer output signals. still other examples depict how output compares can be used for software timing. 10.1 general description this timer system is based on a free-running 16-bit counter with a four-stage program- mable prescaler. a timer overflow function allows software to extend the timing capa- bility of the system beyond the 16-bit range of the counter. three independent input- capture functions are used to automatically record (latch) the time when a selected transition is detected at a respective timer input pin. five output-compare functions are included for generating output signals or for timing software delays. since the input- capture and output-compare functions may not be familiar to all users, these concepts are explained in greater detail. a programmable periodic interrupt circuit called the real-time interrupt (rti) is tapped off of the main 16-bit timer counter. software can select one of four rates for the rti, which is most commonly used to pace the execution of software routines. the computer operating properly (cop) watchdog function is loosely related to the main timer in that the clock input to the cop system (e ? 2 15 ) is tapped off the free- running counter chain. the clocking structure for this system will be discussed briefly in this section, but the overall cop system is explained in greater detail in section 5 resets and interrupts . the timer subsystem involves more registers and control bits than any other sub- system on the mcu. each of the three input-capture functions has its own 16-bit time capture latch (input-capture register) and each of the five output-compare functions has its own 16-bit compare register. all timer functions, including the timer overflow and rti have their own interrupt controls and separate interrupt vectors. additional control bits permit software to control the edge(s) that trigger each input-capture func- tion and the automatic actions that result from output-compare functions. although hardwired logic is included to automate many timer activities, this timer architecture is essentially a software-oriented system. this structure is easily adaptable to a very
motorola main timer and real-time interrupt m68hc11 10-2 reference manual wide range of applications although it is not as efficient as dedicated hardware for some specific timing applications. 10.1.1 overall timer block diagram figure 10-1 is an overall block diagram of the main timer system. it will be helpful to refer to this figure as the detailed explanations of the various control registers and bits are discussed in the remainder of this section, which helps put these details in context with the overall timer system. the port a pin control block includes logic for timer functions and for general-purpose i/o. for pins pa0, pa1, and pa2, this block contains edge-detection logic as well as control logic that allows the user to select which edges will trigger an input capture. the digital level on these pins can be read at any time (read porta register) even if the pin is being used for the input-capture function. pins pa[6:3] are used for general- purpose output or as output-compare pins. when one of these pins is being used for an output-compare function, it cannot be written directly as if it were a general-purpose output. each of the output-compare functions (oc[5:2]) is related to one of the port a output pins. output compare one (oc1) has extra control logic, allowing it to optionally control any combination of the pa[7:3] pins. this extra logic is presented in 10.4.2 ad- vanced i/o pin control using oc1 . the pa7 pin can be used as a general-purpose i/o pin, as an input to the pulse accumulator, or as an oc1 output pin. the timer functions of these pins are discussed in detail throughout this section. in some cases, a user may need more detailed information about the logic associated with these pins, especially when part of port a is being used for timer i/o and the rest is being used for general-purpose i/o. the best source for such details appears in 7.3.1 port a , which includes complete logic diagrams for all of the port a pins. 10.1.2 input-capture concept the input-capture function is a fundamental element of the timer architecture of the MC68HC11a8. for the mcu, physical time is represented by the count in the 16-bit free-running counter. this counter is the central element in the main timer system. in- put-capture functions, used to record the time at which some external event occurred, are accomplished by latching the contents of the free-running counter when a selected edge is detected at the related timer input pin. the time at which the event occurred is saved in the input capture register (16-bit latch); therefore, although it may take an un- determined variable amount of time to respond to the event, software can tell exactly when the event occurred. by recording the times for successive edges on an incoming signal, software can de- termine the period and/or pulse width of the signal. to measure a period, two succes- sive edges of the same polarity are captured. to measure a pulse width, twoalternate polarity edges are captured. for example, to measure the pulse width for a high-going pulse, the user would capture at a rising edge and subtract this time from the time cap- tured for the subsequent falling edge. when the period or pulse width is less than a full 16-bit counter overflow period, the measurement is very straightforward. in practice, software usually has to keep track of the overflows of the 16-bit counter to extend its
m68hc11 main timer and real-time interrupt motorola reference manual 10-3 range. figure 10-1 main timer system block diagram another important use for the input-capture functions is to establish a time reference. in this case, an input-capture function is used in conjunction with an output-compare function. for example, if the user wishes to activate an output signal a certain number of clock cycles after detecting an input event (edge), the input-capture function would be used to record the time at which the edge occurred. a number corresponding to the mcu e clk 16-bit latch clk pa0/ic3 4 3 5 6 7 8 2 1 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 port a pin control oc1i oc2i oc3i oc4i i4/o5i ic1i ic2i ic3i tflg 1 status flags foc1 foc2 foc3 foc4 foc5 oc1f oc2f oc3f oc4f i4/o5f ic1f ic2f ic3f pa1/ic2 pa2/ic1 pa3/oc5/ ic4/oc1 pa4/oc4/ oc1 pa5/oc3/ oc1 pa6/oc2/ oc1 pa7/oc1/ pai i4/o5 16-bit comparator = toc1 (hi) toc1 (lo) 16-bit comparator = toc2 (hi) toc2 (lo) 16-bit comparator = toc3 (hi) toc3 (lo) 16-bit comparator = toc4 (hi) toc4 (lo) 16-bit latch tic1 (hi) tic1 (lo) clk 16-bit latch tic2 (hi) tic2 (lo) clk 16-bit latch tic3 (hi) tic3 (lo) clk 16-bit comparator = ti4/o5 (hi) ti4/o5 (lo) 16-bit free running counter tcnt (hi) tcnt (lo) 9 toi tof interrupt requests (further qualified by i bit in ccr) taps for rti, cop watchdog, and pulse accumulator prescaler divide by 1, 4, 8, or 16 pr1 pr0 16-bit timer bus oc5 ic4 to pulse accumulator tmsk 1 interrupt enables cforc force output compare pin functions
motorola main timer and real-time interrupt m68hc11 10-4 reference manual desired delay would be added to this captured value and stored to an output-compare register. since both input captures and output compares are referenced to the same 16-bit counter, the delay can be controlled to the resolution of the free-running counter independent of software latencies. details about the implementation of the input-cap- ture functions as well as more specific examples of how to use input-capture functions in the MC68HC11a8 are included in 10.3 input-capture functions . 10.1.3 output-compare concept the output-compare function is also a fundamental element of the timer architecture of the MC68HC11a8. for the mcu, physical time is represented by the count in the 16-bit free-running counter. this counter is the central element in the main timer sys- tem. output-compare functions are used to program an action to occur at a specific time (when this 16-bit counter reaches a specific value). for each of the five output- compare functions, there is a separate 16-bit compare register and a dedicated 16-bit comparator. the value in the compare register is compared to the value of the free- running counter on every bus cycle. when the compare register matches the counter value, an output is generated, which sets an output-compare status flag and initiates the automatic actions for that output-compare function. optional automatic actions ini- tiated by an output compare include generation of a hardware interrupt request and state changes at the related timer output pin(s). one of the easiest uses of an output-compare function is to produce a pulse of a spe- cific duration. first, a value corresponding to the leading edge of the pulse is written to the output-compare register. the output compare is configured to automatically set the corresponding output either high or low, depending on the polarity of the pulse be- ing produced. after this compare occurs, the output compare is reprogrammed to au- tomatically change the output pin back to its inactive level at the next compare. a value corresponding to the width of the pulse is added to the original output-compare regis- ter value, and this result is written to the output-compare register. since the pin-state changes occur automatically at specific values of the free-running counter, the pulse width can be controlled accurately to the resolution of the free-running counter inde- pendent of software latencies. by repeating the actions for generating pulses, an out- put signal of a specific frequency and duty cycle can be generated. another use of the output-compare function is to generate a specific delay. for exam- ple, to produce a 10-ms delay to time programming of an eeprom byte, follow the initial programming steps to the point where the programming supply has been en- abled (eepgm bit has been written to one). read the current value of the main timer counter and add a number corresponding to 10 ms (if the count rate is 2 mhz, the val- ue corresponding to 10 ms would be 20,000 10 or $4e20). write this sum to the output- compare register so that an interrupt will occur when the counter gets to this value. in this example, the actual eeprom programming time started just before the current time was read from the counter and ended after responding to the output compare and turning off eepgm. the small delays for setting up the output compare and the latency for responding to the output compare are not considered because they only make the eeprom programming time longer by a few microseconds. a more advanced user of output-compare functions will learn how to correct for these details, although it is often
m68hc11 main timer and real-time interrupt motorola reference manual 10-5 not necessary. details about the implementation of the output-compare functions and specific examples of how to use output-compare functions in the MC68HC11a8 are included in 10.4 output-compare functions . 10.2 free-running counter and prescaler the central element of the main timer system in the MC68HC11a8 is a 16-bit free-run- ning counter. this counter starts from a count of $0000 as the mcu is coming out of reset and then counts up continuously. when the maximum count is reached ($ffff), the counter rolls over to a count of $0000, sets an overflow flag, and continues to count up. as long as the mcu is running in a normal operating mode, there is no way to re- set, change, or interrupt the counting of this counter. this counter may be read at any time to tell what time it is. all activities of the main timer system are referenced to this one free-running counter; therefore, all timer functions have a known relationship to each other. the timer counter (tcnt) register is meant to be read using a double-byte read in- struction such as load d (ldd) or load x (ldx). the low-order half of the counter pass- es through a normally transparent buffer to the tcnt register. when the low-order half of the counter is read using a single-byte read instruction, the value returned is simply the value of the low-order eight bits of the main timer counter. when the high-order byte of the tcnt register is read, the transparent buffer on the low-order byte of the tcnt register is inhibited for one bus cycle. in the case of a double-byte read of tcnt, the high-order byte is accessed first, which returns the high-order count value and, at the same time, freezes the low-order count value buffer, which is read during the next bus cycle. this procedure assures that the two bytes read from tcnt belong with each other. the count value that is returned on a double-byte read corresponds to the value of the free-running counter at the second-to-last cycle of the double-byte read instruction. this and other subtle timing details related to the main timer are dis- cussed in 10.5 timing details for the main timer system . 10.2.1 overall clock divider structure the following figures, registers, and paragraphs describe the major clock divider chains for the entire mcu system. the largest chain includes the 16-bit timer counter and its associated prescaler. clocks for the pulse accumulator system, rti, and cop watchdog branch off the main timer clocking chain. the alternative to tapping these slower clocks off the main timer chain would have been to build additional clock divider chains, which would have used expensive chip area. these taps off the main timer clocking chain have special circuitry to compensate for the main timer prescaler so that the clock frequency at these taps is independent of the prescale factor. these postscaler circuits make it practical to share portions of the timer clocking chain in a way that still allows the rates of the various systems to be selected independent of tcnt timer counter $100eC$100f bit 7 654321 bit 0 bit 15 bit 8 $100e bit 7 bit 0 $100f
motorola main timer and real-time interrupt m68hc11 10-6 reference manual each other. there is a relatively complex block of logic that divides the 4 x oscillator clock down to the internal phase 2 (ph2) clocks and the external e clock. the address strobe (as) signal for demultiplexing the low-order address from data is also developed in this first oscillator divider block. almost everything that happens inside the mcu is referenced to the internal ph2 clocks rather than the e clock, which lags 90 behind the internal ph2 clocks. users who are familiar with the older mc6800 and mc6801 families should note that this phase shift between e and ph2 is different from what they are used to. from an external point of view, they can still think of bus cycles as starting and ending on falling edges of e, but they will notice a big improvement in address and data hold times relative to this edge. figure 10-2 shows idealized timing relationships for the clocks and as that are devel- oped in the initial oscillator divider block. since this section is devoted to the main timer system, these clocks will not be discussed in any great detail; figure 10-2 is presented for reference only. for more information concerning these signals, refer to section 2 pins and connections and figure 7-12 . the logic associated with the stop power-saving mode also contributes to the com- plexity of the initial oscillator divider block. when the stop mode is exited, the internal clocks resume before the external e clock starts. the pulse accumulator can be clocked by an external source (event counting mode) or an internal source (time accumulation mode). the internal clocking source is an e divided by 64 rate clock, which is tapped off of the main timer clocking chain. the pulse accumulator is described in more detail in section 11 pulse accumulator , but the e divided by 64 tap is discussed in this section since it is tapped off the main timer. the pulse accumulator tap is also used to inhibit write permission to the time-protected control registers and bits. certain registers and bits, such as the timer prescaler control bits in the tmsk2 register, can only be written within the first 64 e-clock cycles after reset. figure 10-2 timing summary for oscillator divider signals one bus cycle extal ph2 e as address/data data addr
m68hc11 main timer and real-time interrupt motorola reference manual 10-7 the divider chains for the serial peripheral interface (sp[) clock rate and the serial communications interface (sci) baud-rate generator are the last two major clock divid- er chains in the mcu. the 4,064 bus-cycle oscillator startup delay at powerup and af- ter stop is derived from the sci baud-rate counter. like the main timer divider chain, this divider is free running and uninterruptable except by special commands available only in special test modes. figure 10-3 , which illustrates all of the major clock divider chains in the MC68HC11a8, will help the user understand how the timer fits into the overall mcu system. the main timer counter and its prescaler and derived clock chains for rti and cop watchdog are described in more detail in subsequent paragraphs. 10.2.1.1 prescaler a programmable prescaler allows the user to select one of four clocking rates to drive the 16-bit main timer counter. this choice allows the programmer to make a trade-off between timer resolution and timer range. the default fastest rate causes the main timer counter to clock at the e-clock rate, which results in a timer resolution of 500 ns and a timer range of 32.77 ms between overflows (fo re=2 mhz). the slowest rate (largest prescale factor) causes the main timer counter to clock at an e divided by 16 rate, which results in timer resolution of 8 m s and a timer range of 524.3 ms between overflows (for e = 2 mhz). the timer range is important because the software needed for timing functions is more complex if timer overflows must be considered. if time periods are known to be less than the time between successive overflows, then the overflows can be ignored, and time periods are calculated using simple 16-bit arithmetic instructions (even if an over- flow occurs within the timed period). the overflow from 16-bit arithmetic instructions behaves just like an overflow from the 16-bit counter. to illustrate this point, if the timer counter is near its maximum count ($fff0) and an output compare is desired in 100 10 cycles, add $fff0 plus $0064 (modulo $ffff) to get $0054 (in base ten modulo 65,536, that would be 65,520 + 100 = 84). then write this result ($0054) to an output- compare register. in 100 cycles, the timer counter will have overflowed and counted up to $0054 where the output compare will occur. when overflow has to be consid- ered, timing calculations become much more complicated. another factor to consider in selecting the prescaler rate is power consumption. since cmos power consumption is directly proportional to its frequency of operation, power is saved by reducing frequency. the amount of logic driven by the prescaled timer clock is fairly small compared to the amount of logic driven by the ph2 clock, but some savings will still result from selecting a slower count rate. the user should consider resolution needed and the longest time period needed (or the length of the longest pulse needed). as an example, consider measuring periods between 10 ms and 100 ms. for an e-clock frequency of 2 mhz, a prescale division factor of 4 would result in a timing range of 131.1 ms; therefore, overflows could be ignored in calculations. since the resolution would be 2 m s, an error of one count would represent an error of 0.02 percent of the shortest expected pulse (10 ms). for most applications, this accuracy is more than required.
motorola main timer and real-time interrupt m68hc11 10-8 reference manual when software has to handle overflows, the latency and execution time of the overflow service routine can become a factor in the overall accuracy of timer output functions. for example, consider the case where an output compare coincidentally occurs short- ly after a timer overflow. in the most straightforward approach to generating pulses that are longer than the range of the timer counter, the output compare is not resched- uled until after a certain number of overflows. if the output compare occurs on a very low counter value (shortly after an overflow), the value could pass by while the over- flow routine is being executed. since the desired time for the output compare has al- ready passed, the output compare is forced rather than being scheduled. because this forced compare is subject to software latencies rather than being strictly referenced to the timer counter, an error will occur in the timing of the generated output signal. these errors can be avoided by careful software treatment; however, this example demon- strates some of the costs of using an unnecessarily small prescaler value.
m68hc11 main timer and real-time interrupt motorola reference manual 10-9 figure 10-3 major clock divider chains in the MC68HC11a8 oscillator and clock generator ( ? 4) xtal extal ? 2 ? 2 1:0 ? 2 1:1 ? 2 ? 2 ? 2 ? 2 1:1 0:1 ? 2 ? 2 ? 2 ? 2 ? 2 ? 2 ? 2 ? 2 ? 2 timer overflow timer bus (16 bits) postscaler pr1:pr0 1:0 1:1 0:0 0:1 postscaler pr1:pr0 cbyp ? 2 ? 2 ? 4 0:0 pr1:pr0 0:1 1:0 1:1 external bus clock (e) address strobe (as) ph2 internal bus clock (ph2) ? 3 ? 4 ? 13 0:0 scp1:scp0 0:1 1:0 1:1 prescaler ? 2 ? 2 0:0:1 0:0:0 0:1:0 ? 2 0:1:1 scr2:scr1:scr0 ? 2 ? 2 1:0:1 1:0:0 1:1:0 ? 2 ? 2 1:1:1 ? 4 ? 2 0:1 0:0 1:0 ? 2 1:1 spr1:spr0 ? 2 ? 2 ? 2 0:1 0:0 1:0 ? 2 1:1 rtr1:rtr0 0:1 1:0 ? 4 1:1 ? 4 ? 4 0:0 clear cop timer system reset cr1:cr0 ? 16 sci receive baud rate (16x) sci transmit baud rate (1x) spi bit rate real time interrupt to pulse accumulator (e ? 64) s r q q ff1 s r q q ff2 force cop reset always e ? 2 6 always e ? 2 15 always e ? 2 13 cbyp
motorola main timer and real-time interrupt m68hc11 10-10 reference manual the following register and paragraphs explain the prescaler select bits, pr1 and pr0, which are in the timer mask register 2 (tmsk2). the other bits in this register are not related to the timer prescaler. pr[1:0] timer prescaler select these two bits select the prescale rate for the main 16-bit free-running timer system. table 10-1 shows the relationship between the prescale factor and the value of these control bits. a prescale factor of one corresponds to an e divided by one rate for the main timer; whereas, a prescale factor of 16 corresponds to a timer count rate of e divided by 16. in normal modes, this prescale rate can only be changed once within the first 64 bus cycles after reset, and the resulting count rate stays in effect until the next reset. 10.2.1.2 overflow in cases where periods greater than the range of the timer counter have to be mea- sured or produced, the timer overflow must be used, which is similar to measuring times greater than 60 seconds by using the seconds display of a digital clock. the minute and hour displays can be thought of as software counters, which extend the range of the seconds counter. each time the seconds counter overflows (goes from 59 to 0), the minutes counter is incremented. if a period less than 60 seconds is desired, add (modulo 60) the desired number of seconds to the starting time to get the ending time. in the MC68HC11a8, the timer overflow flag (tof) status bit is set each time the timer counter overflows from $ffff to $0000. this bit can optionally generate an automatic interrupt request each time it is set by setting the timer overflow interrupt (toi) enable bit in the timer mask register 2 (tmsk2). software must acknowledge that it has seen the overflow condition by clearing the tof status indicator. the free-running counter continues to run even if the tof status indicator is not cleared. if overflow indications are not important to a particular application, they may be ignored. the following regis- ters and paragraphs describe the tof status bit and the toi interrupt enable. the oth- tmsk2 timer interrupt mask register 2 $1024 bit 7 654321 bit 0 toi rtii paovi paii 0 0 pr1 pr0 reset: 00000000 table 10-1 crystal frequency vs. pr1, pr0 values pr1 pr0 prescale fac- tor crystal frequency 2 23 hz 8 mhz 4 mhz one count (resolution)/overflow (range) 0 1 1 1 0 0 0 1 1 4 8 16 477 ns/31.25 ms 191 m s/125 ms 3.81 m s/250 ms 7.63 m s/.05 s 500 ns/32.77 ms 2 m s/131.1 ms 4 m s/62.1 ms 8 m s/524.3 ms 1 m s/65.54 ms 4 m s/262.1 ms 8 m s/524.3 ms 16 m s/1.049 s 2.1 mhz 2 mhz 1 mhz bus frequency (e clock)
m68hc11 main timer and real-time interrupt motorola reference manual 10-11 er bits in these registers are not associated with the timer overflow. toi, tof timer overflow interrupt enable, timer overflow flag the tof status bit is automatically set to one each time the free-running 16-bit counter rolls over from $ffff to $0000. this status bit is cleared by writing to the tflg2 reg- ister with a one in the corresponding data bit position (bit 7). the toi control bit allows the user to configure the timer overflow for polled or interrupt-driven operation but does not affect the setting or clearing of the tof bit. when toi is zero, timer overflow interrupts are inhibited, and the timer overflow is operating in a polled mode. in this mode, the tof bit must be polled (read) by user software to determine when an over- flow has occurred. when the toi control bit is one, a hardware interrupt request is generated whenever the tof bit is set to one. before leaving the interrupt service rou- tine, software must clear the tof bit by writing to the tflg2 register (see 10.2.4 tips for clearing timer flags ). 10.2.1.3 counter bypass (test mode) in special modes of operation (test and bootstrap), there is a counter bypass function to simplify testing of the main timer functions. this function is activated by writing a one to the counter bypass (cbyp) control bit in the test1 control register, which can only be written in the special modes. when cbyp is one, the main timer counter is recon- figured so that the prescaler is bypassed and the upper and lower halves of the 16-bit counter are simultaneously driven by the internal ph2 clock. this dramatically reduces testing time for the main timer. the functions that are tapped off of the main timer would have erroneous timing while the cbyp function is enabled. since this configuration is only possible in special test modes, it does not interfere with any use of the systems in normal modes. 10.2.2 real-time interrupt (rti) function the rti function can be used to generate hardware interrupts at a fixed periodic rate. a common software practice is to organize the routines that compose the software for an application into a sequence of major subroutine calls. the length of time required to execute all of the routines is a variable, which depends upon how much each routine had to do, but the worst-case time to execute the entire sequence of routines should be known. after completing a pass through all the routines, software enters a delay mode until a time reference signal is detected. upon detecting this signal, a jump is tmsk2 timer interrupt mask register 2 $1024 bit 7 654321 bit 0 toi rtii paovi paii 0 0 pr1 pr0 reset: 00000000 tflg2 timer interrupt flag register 2 $1025 bit 7 654321 bit 0 tof rtif paovf paif 0000 reset: 00000000
motorola main timer and real-time interrupt m68hc11 10-12 reference manual performed to the top of the sequence, and all the subroutines are again executed in sequence. by knowing the time between successive time reference signals, a routine can measure real time by noting the number of times it is executed and multiplying by the time between successive time reference signals (in this case, the rti period). in the MC68HC11a8, the rti system can be used to provide this periodic time refer- ence signal. to accommodate the needs of a variety of applications, four different rates are available for the rti signal. these rates are a function of the mcu oscillator frequency and the value of two software-accessible control bits (rtr1 and rtr0). al- though the rate can be changed at any time, it is typically established shortly after reset and left alone. the clock source for the rti function is a free-running clock that cannot be stopped or interrupted. this clock causes the time between successive rti time-outs to be a con- stant, which is independent of the software latencies associated with flag clearing and service. thus, an rti period starts from the previous rti time-out, not from when rtif is cleared. the most common problem users encounter with the rti system is that they forget to clear rtif after it is recognized. if the flag is not cleared by a specific software write to the tflg2 register, it will already be pending the next time it is checked. if the sys- tem is being used in an interrupt-driven mode, the interrupt will be requested and ser- viced immediately after the return from interrupt (rti) instruction is executed at the end of the rti service routine. this sequence results in a system lockup where the rti service routine is executed continuously to the exclusion of all else. the only way out of this infinite loop is a system reset. if the rti system is operating in a polled mode, the main routine sequence will operate correctly the first time and wait until rtif is set the first time. as soon as rtif is set, the jump is executed back to the top of the sequence as expected. the routines will be executed the second time and soft- ware should wait for the end of the next rti period, but, since rtif is still set, software thinks the rti period has already expired. the result will be that the main sequence is repeated too quickly. the following registers and paragraphs explain the rti flag and rti enable. the other bits in these registers are not related to the rti system. rtii, rtif real-time interrupt enable, real-time interrupt flag the rtif status bit is automatically set to one at the end of every rti period. this sta- tmsk2 timer interrupt mask register 2 $1024 bit 7 654321 bit 0 toi rtii paovi paii 0 0 pr1 pr0 reset: 00000000 tflg2 timer interrupt flag register 2 $1025 bit 7 654321 bit 0 tof rtif paovf paif 0000 reset: 00000000
m68hc11 main timer and real-time interrupt motorola reference manual 10-13 tus bit is cleared by writing to the tflg2 register with a one in the corresponding data bit position (bit 6). the rtii control bit allows the user to configure the rti system for polled or interrupt-driven operation but does not affect the setting or clearing of rtif. when rtii is zero, interrupts are inhibited, and the rti system is operating in a polled mode. in this mode, the rtif bit must be polled (sampled) by user software to deter- mine when an rti period has elapsed. when the rtii control bit is one, a hardware interrupt request is generated each time rtif is set to one. before leaving the interrupt service routine, software must clear rtif by writing to the tflg2 register (see 10.2.4 tips for clearing timer flags ). the following register and paragraphs explain the rti rate select bits in the pulse ac- cumulator control register (pactl). the other bits in this register are not related to the rti system. rtr1, rtr0 real-time interrupt rate selects these two bits determine the rate at which interrupts will be requested by the rti sys- tem. the rti system is driven by an e divided by 2 13 rate clock compensated so that it is independent of the timer prescaler. these two control bits select an additional di- vision factor. table 10-2 shows the rti rates that result for various combinations of crystal frequency and rti rate-select control bit values. rti is set to its fastest rate by default out of reset and may be changed at any time. 10.2.3 cop watchdog function the cop watchdog function is only superficially related to the main timer system. the clocking chain for the watchdog function is tapped off of the main timer divider chain. figure 10-3 illustrates how the cop clock is derived from the main timer clocking chain. although the cop clocking chain is discussed briefly, the cop system is ex- plained in greater detail in section 5 resets and interrupts . the counter stages up to the e divided by 2 15 tap have no reset input; whereas, the divider stages after this tap are reset each time the cop clearing sequence is execut- pactl pulse accumulator control $1026 bit 7 654321 bit 0 ddra7 paen pamod pedge 0 0 rtr1 rtr0 reset: 00000000 table 10-2 rti rates vs. rtr1, rtr0 for various crystal frequencies rtr1 rtr0 e ? 2 13 divided by crystal frequency 2 23 hz 8 mhz 4 mhz nominal rti rate 0 0 1 3.91 ms 4.10 ms 8.19 ms 0 1 2 7.81 ms 8.19 ms 16.38 ms 1 0 4 15.62 ms 16.38 ms 32.77 ms 1 1 8 31.25 ms 32.77 ms 65.54 ms 2.1 mhz 2 mhz 1 mhz bus frequency (e clock)
motorola main timer and real-time interrupt m68hc11 10-14 reference manual ed (see figure 10-3 ). this structure determines the uncertainty of the cop time-out period because software has no practical way of knowing when the first clocking edge will appear at the e divided by 2 15 tap relative to the cop clearing sequence. for a bus frequency of 2 mhz (e), the first clock can appear at the e divided by 2 15 tap any- where between ~0 to 16.4 ms after a cop clearing sequence. this tolerance or un- certainty depends on the bus frequency (e) but does not vary with respect to the rate selects (cr1, cr0). the following register and paragraphs explain the cop timer rate select bits located in the options control register (option). the other bits in this register are not related to the main timer system or the cop system. cr1, cr0 cop timer rate select bits the mcu internal e clock is first divided by 2 15 before it enters the cop watchdog sys- tem. the cr1 and cr0 control bits regulate a further scaling factor for the watchdog timer as shown in table 10-3 . the columns at the right of the table show the resulting watchdog time-out periods for three typical oscillator frequencies. after reset, the time- out period is configured for the shortest time-out period by default. in normal operating modes, these bits can only be written once, and that write must be within 64 bus cycles after reset. 10.2.4 tips for clearing timer flags the most common method of clearing a status flag bit in the timer flag registers is to load an accumulator with a mask that has a one in the bit(s) corresponding to the flag(s) to be cleared; then write this value to tflg1 or tflg2. a bit clear (bclr) in- struction can also be used to clear a flag in tflg1 or tflg2. the mask, which is sup- plied with the bclr instruction, should have zeros in the bit positions corresponding to the flags to be cleared and ones in all other bits. to clear the tof flag, execute bclr tflg2 with a mask of %01111111. the bclr instruction will read tflg2, and it with the inverse of the supplied mask (%10000000 in this case), and write the result option system configuration options $1039 bit 7 654321 bit 0 adpu csel irqe dly cme 0 cr1 cr0 reset: 00000000 table 10-3 cop time-out vs. cr1, cr0 values cr1 cr0 e ? 2 15 divided by crystal frequency 2 23 hz 8 mhz 4 mhz nominal time-out 0 0 1 15.625 ms 16.384 ms 32.768 ms 0 1 4 62.5 ms 65.536 ms 131.07 ms 1 0 16 250 ms 262.14 ms 524.29 ms 1 1 64 1 s 1.049 s 2.1 s 2.1 mhz 2 mhz 1 mhz bus frequency (e clock)
m68hc11 main timer and real-time interrupt motorola reference manual 10-15 back to tflg2. the condition of the other flags in the register is not important, even if they become set in the middle of the bclr instruction, because the write cycle of the instruction will write zeros to all bits except those corresponding to flags that are to be cleared. writing a zero to a bit corresponding to a flag that is set does not disturb the flag. it is not appropriate to use the bit set (bset) instruction to clear flags in the timer flag registers because this could inadvertently clear one or more of the other flags in the register. again, consider the case of clearing the tof bit. suppose rtif is set after the tof interrupt is recognized but before the bset instruction is started. the bset instruction is a read-modify-write instruction that reads the operand, ors this with a mask having ones in the bit(s) to be set, and writes the resulting value back to the op- erand address. using this instruction on tflg1 or tflg2 will clear all flags that are set at the time the operand (in this case, the tflg2 register) is read. there are many instruction sequences that can be used to clear timer flags. in general, each sequence takes a different number of bytes of object code and a different number of cycles of execution time. the best sequence depends on a number of factors, in- cluding (but not limited to) whether the user wants minimum execution time or mini- mum program memory space. in many cases, the subtle differences in program size and execution time are unimportant, and any of the sequences shown would be equal- ly acceptable. some sequences require registers to be in the direct addressing mode memory space ($0000C$00ff), which is not practical in many applications. since oth- er sequences use indexed addressing, their efficiency will depend on whether or not the index register already points to the register space (extra instructions and time are required if the index register has to be changed). table 10-4 illustrates seven different instruction sequences that could be used to clear the tof status bit in tflg2. 10.3 input-capture functions each input-capture function includes a 16-bit latch, input edge-detection logic, and in- terrupt generation logic. the 16-bit latch captures the current value of the free-running counter when a selected edge is detected at the corresponding timer input pin. the table 10-4 instruction sequences to clear tof instruction sequence opcode operand(s) address mode bytes cycles total sequence bytes cycles 1 ldaa staa #$80 motorola main timer and real-time interrupt m68hc11 10-16 reference manual edge-detection logic includes control bits so that user software can select the edge po- larity that will be recognized. each of the three input-capture functions can be indepen- dently configured to detect rising edges only, falling edges only, or any edge (rising or falling). the interrupt generation logic includes a status flag, which indicates that an edge has been detected, and a local interrupt enable bit, which determines whether or not the corresponding input-capture function will generate a hardware interrupt re- quest. if the interrupt request is inhibited, the input capture is operating in polled mode where software must read the status flag to recognize that an edge was detected. input-capture edges are generally asynchronous to the internal timer counter, which is clocked relative to the ph2 clock. these asynchronous capture requests are then synchronized to ph2 so that the actual latching will occur on the opposite half cycle of ph2 from when the timer counter is being incremented. this synchronization process introduces a delay from when the actual edge occurs to when the counter value is latched. in almost all cases, this very short delay should be ignored. when the time between two edges is being measured, both edges are subject to the same delay; therefore, these delays will offset each other. when an input capture is being used in conjunction with an output compare, there will be a similar delay between the actual compare point and when the output pin actually changes state. when a prescale factor other than one is being used, the capture delay is smaller than the uncertainty due to timer resolution. detailed information about timer system delays is given in 10.5 tim- ing details for the main timer system . the central element of each input-capture function is the input-capture latch, which can be read by software as a pair of 8-bit reg- isters (see the following input-capture registers). the tlcx registers are not affected by reset and cannot be written by software. when an edge has been detected and syn- chronized, the 16-bit free-running counter value is transferred into the input-capture register pair as a single 16-bit parallel transfer. timer-counter value captures and tim- er-counter incrementing occur on opposite half cycles of the ph2 clock so that the count value is stable whenever a capture occurs. the input-capture functions operate independently of each other, and all three functions can capture the same 16-bit count value if the input edges are all detected within the same timer count cycle. a read of the high-order byte of an input-capture register pair inhibits a new capture transfer for one bus cycle. as long as a double-byte read instruction such as load d (ldd) is used to read input-capture values, the user is assured that the two bytes be- long with each other. if a new input-capture occurs so that a transfer would have oc- curred immediately after the high-byte read, it will be delayed for one more cycle but will not be lost. bit 7 654321 bit 0 $1010 bit 15 bit 8 tic1 $1011 bit 7 bit 0 $1012 bit 15 bit 8 tic2 $1013 bit 7 bit 0 $1015 bit 7 bit 0
m68hc11 main timer and real-time interrupt motorola reference manual 10-17 the latching action of an input-capture function occurs every time a selected edge is detected on the corresponding timer input pin (even if the corresponding input-capture flag is already set). this means that the value read from the input-capture register cor- responds to the most recent edge at the pin, which may not be the edge that caused the input-capture flag to be set. in a few applications, there could be a number of close- ly spaced edges (i.e., an unfiltered bouncing switch contact). in cases where these ex- tra captures are undesirable, software can write to the edge-select control bits to inhibit further captures until after the current capture has been handled. the following registers and paragraphs explain the input-capture status flags and the local interrupt enable control bits for the input-capture functions. icxi, icxf input capture interrupt enables and input capture flags (x = 1, 2, or 3) the icxf status bit is automatically set to one each time a selected edge is detected at the corresponding input-capture pin. this status bit is cleared by writing to the tflg1 register with a one in the corresponding data bit position. the icxi control bit allows the user to configure each input-capture function for polled or interrupt-driven operation but does not affect the setting or clearing of the corresponding icxf bit. when icxi is zero, the corresponding input-capture interrupt is inhibited, and the input capture is operating in a polled mode. in this mode, the icxf bit must be polled (read) by user software to determine when an edge has been detected. when the icxi control bit is one, a hardware interrupt request is generated whenever the corresponding icxf bit is set to one. before leaving the interrupt service routine, software must clear the icxf bit by writing to the tflg1 register (see 10.2.4 tips for clearing timer flags ). 10.3.1 programmable options the user can program each input-capture function to detect a particular edge polarity on the corresponding timer input pin. a pair of control bits (edgxb, edgxa) in the tim- er control register 2 (tctl2) are used to select the edge(s) detected by each input- capture function. tmsk1 timer interrupt mask 1 register $1022 bit 7 654321 bit 0 oc1i oc2i oc3i oc4i oc5i ic1i ic2i ic3i reset: 00000000 tflg1 timer interrupt flag 1 register $1023 bit 7 654321 bit 0 oc1f oc2f oc3f oc4f oc5f ic1f ic2f ic3f reset: 00000000 tctl2 timer control register $1021 bit 7 654321 bit 0 0 0 edg1b edg1a edg2b edg2a edg3b edg3a reset: 00000000
motorola main timer and real-time interrupt m68hc11 10-18 reference manual edgxb, edgxa input capture edge control (x = 1, 2, or 3) these pairs of bits determine which edge(s) the input-capture functions will be sensi- tive to. these bit pairs are encoded as shown in the following table: 10.3.2 using input capture to measure period and frequency timer examples 10C1(a) and 10C1(b) show how to measure a period using an input- capture function. a complete assembly listing for all timer section examples is shown in 10.6 listing of timer examples . timer example 10C1(a) measures the time be- tween two successive rising edges on an input signal at the pa2/ic1 pin. this program uses the input-capture function in polled mode for demonstration because it is a little simpler than the interrupt-driven operation. other examples in this section will demon- strate interrupt-driven operation, which is often a more flexible approach because the mcu can be performing other tasks while waiting for a particular timer event. example 10C1(b) changes the period obtained from example 10C1(a) into a frequency to display the results in a more familiar form. also, support routines are provided to convert hexadecimal numbers into decimal numbers. when running the example, a period is measured at the ic1 pin and displayed as a decimal period (in e cycles) and as a frequency (in hz). after printing the result, the program returns to its start and re- peats continuously. depending on the display-device speed and the signal at ic1, a screen can be filled with results very quickly. to stop, just press the reset button on the evb board. figure 10-4 shows the critical instructions in the measurement of the period of the sig- nal at the pa2/ic1 pin. the numbers in square brackets in the listings indicate the number of mcu e cycles needed to execute each instruction. this information is used in the timing analysis presented in figure 10-5 . the timing analysis for example 10C1 is shown in figure 10-5 , which is very detailed to show exactly what occurs in an input capture. software instructions are used to read the first captured value, to prepare for the second capture, and to reset the input-cap- ture flag. these instructions require a finite amount of time. if the period of the signal being measured is too short, the second edge can come before the program is ready for it. this period will determine the highest frequency that can be measured with this example program. if the signal period being measured is longer than the range of the 16-bit timer counter, then two periods, which are exactly one overflow time apart, are not distinguishable. since this program does not consider overflows, this period will determine the lowest frequency that can be measured with this program. these limi- tations are program limits, and, as shown in other examples, the input-capture func- tions can be used to measure much shorter or much longer periods. edgxb edgxa configuration 0 0 capture disabled 0 1 capture on rising edges only 1 0 capture on falling edges only 1 1 capture on any edge (rising or falling)
m68hc11 main timer and real-time interrupt motorola reference manual 10-19 * ready to detect first rising edge c00e 1f 23 04 fc[7] brclr tflg1,x $04 *loop here until edge * first edge detected c012 ec 10 [5] ldd tic1,x read time of first edge c014 fd d00d [5] std frste save first capture value c017 86 04 [2] ldaa #$04 c019 a7 23 [4] staa tflg1,x clear ic1f before next edge * ready to capture time of second edge c01b 1f 23 04 fc[7] brclr tflg1,x $04 *loop here until edge * second edge detected c01f ec 10 [5] ldd tic1,x read time of second edge c021 b3 d0 0d [6] subd frste 2nd - 1st -> d c024 fd d0 0f [5] std perc save result (period in cycles) figure 10-4 measuring a period with input capture figure 10-5 timing analysis for example 10C1 as shown in example 10C1(a), the cpu repeats the brclr instruction continuously, waiting for the first rising edge. since the edge is asynchronous to the program exe- cution, where the edge will occur relative to this program is uncertain. this uncertainty leads to a best-case and a worst-case minimum period that can be measured by this program. the worst case arises if the edge is detected too late to be seen by the brclr instruction at [1]. the best case arises when the edge is detected in time to be seen by the brclr instruction at [2]. from the cycle-by-cycle description of the brclr instruction, the read of the operand (tflg1 register in this case) is shown to occur in the third cycle of the instruction. the captured value is read during the last two cycles of the ldd instruction at [3], and the ic1f status flag is cleared during the last cycle of the staa tflg1,x instruction at [4]. although a new capture could occur be- tween [3] and [4], it would be cleared by the staa at [4] and would not be recognized by the program. the earliest place the second edge could occur and be properly han- dled is during the cycle after the status flag clear instruction [4]. this timing analysis is based on a detailed knowledge of timer logic and instruction tim- best case minimum period (20 cycles) e ic1 pin brclr tflg1,x $04 * ldaa #$04 ldd tic1,x brclr tflg1,x $04 * std frste staa tflg1,x brclr tflg1,x $04 * [1] [2] [3] [4] [5] worst case minimum period (27 cycles)
motorola main timer and real-time interrupt m68hc11 10-20 reference manual ing. instruction timing tells which cycle within the instruction actually reads or writes a register. instruction details can be found in appendix a instruction set de- tails . detailed information concerning timer captures is given in 10.5 timing details for the main timer system . for most applications, it is not necessary to study the timing in this much detail, but at least one detailed example should be studied. example 10C1(b), which converts the period from example 10C1(a) into frequency, is more of a demonstration of fdiv and xgdx than anything else. in a real application, the user would normally work with the period value rather than converting it to a fre- quency. some shortcuts were taken since the results were not that critical. for exam- ple, the partial sums were truncated rather than rounding or extending the precision of the calculations. although these shortcuts lead to small errors in the results, these er- rors were not important, considering the resolution of the measurements. to measure the frequency of an incoming signal, a user could accumulate the time of many cycles of the signal and calculate an average period, which would yield much finer resolution than the single-cycle measurement taken in example 10C1. after working with the timer and pulse accumulator for a while, a good exercise might be to develop a way to measure the signal frequency to five digits of accuracy. the following discussion presents a proposed technique that could be tried, although it has not been proven. first, connect the signal to the pulse accumulator input and to an in- put-capture input. capture the time of a first edge and start the pulse accumulator at a count of 256 minus 200. while waiting for 199 cycles of the incoming signal, monitor timer overflows, like example 10C3 does, because 200 cycles of the signal are very likely to take longer than one timer overflow. when the pulse accumulator has counted 199 cycles of the signal, clear the input-capture flag and wait for a capture of the time of the 200th cycle. from the number of overflows and the difference between the final capture value and the first capture value, the user can determine the period of 200 cy- cles of the incoming signal. finally, convert this into frequency. the accuracy is basi- cally one e cycle in 200 cycles of the signal, which corresponds to about 1hzat20 khz, and the accuracy improves for lower frequencies. for very low frequencies, it is not necessary to measure many periods to get the accuracy. try to include a prelimi- nary trial measurement to decide how many cycles should be measured to get the needed accuracy (auto ranging). 10.3.3 using input capture to measure pulse width timer example 10C2 shows how to measure a pulse width with an input capture, which is almost the same as measuring a period, except that the input-capture edge sensi- tivity must be reconfigured between the capture of the first edge and the second edge. since this particular program measures the period of a high-going pulse, the input cap- ture is first configured to capture on a rising edge at the input. after detecting the first edge, the input capture is reconfigured to detect a falling edge. since this program is interrupt driven, it must have an interrupt service routine, which is automatically called as a result of an interrupt, an initialization portion, and a main- line program portion. since this example is only demonstrating the input-capture func- tion, the mainline program will be a trivial two-instruction loop that repeats until a pulse has been measured. in a practical application, the mainline portion would be every-
m68hc11 main timer and real-time interrupt motorola reference manual 10-21 thing other than initialization and interrupt service routines. this example is intended to run on an m68hc11evb evaluation board; thus, the inter- rupt vector will be treated in a somewhat unusual way. the actual interrupt vector for input capture 1 is at $ffee and $ffef, which is in the monitor program eprom on the evb board. to allow use of these vectors, they have been initialized to point at specific ram locations called pseudo-vectors. to use a vector, put a jump (jmp) in- struction to the address of the interrupt service routine at the ram pseudo-vector lo- cations ($00e8, e9, and ea for timer input-capture 1). in a normal application, the address of the service routine would be hard coded into the double-byte vector location rather than writing a jump instruction into ram during initialization. for additional information about interrupts, see section 5 resets and interrupts . the partial listing shown in figure 10-6 depicts the important parts of the pulse-width measurement illustrated in example 10C2. a detailed timing analysis for example 10C2 is shown in figure 10-7 . unlike the pre- vious example, interrupt latencies must be considered to determine the minimum pulse width that can be measured by this program. the instructions in the main pro- gram do not affect the minimum measurable pulse except that the execution time of the longest instruction executing at the time of the interrupt determines the longest possible latency from an input-capture edge to when it can be serviced. the interrupt operation does not begin until the currently executing instruction is completed. if the pulse width being measured is too short, the second edge can come before the pro- gram is ready for it. this time will determine the shortest pulse that can be measured with this example program. as in the previous example, if the signal being measured is longer than the range of the 16-bit timer counter, then two pulse widths, which were different by an exact multiple of the overflow period, are not distinguishable. since this program does not consider overflows, the overflow period of the 16-bit timer will deter- mine the longest pulse that can be measured correctly with this program. these limi- tations are program limits and, as shown in other examples, the input-capture functions can be used to measure much shorter or much longer times. as shown in example 10C2, the cpu repeats the waitl2 loop continuously, waiting for the first rising edge. since the edge is asynchronous to the program execution, where the edge will occur relative to this program is uncertain. this uncertainty leads to a best-case and a worst-case minimum period that can be measured by this pro- gram. the worst case arises when the first edge is not recognized before the end of the beq waitl2 instruction at [1]. in this worst case, the ldaa ic1dun instruction would have to finish, which causes an extra four-cycle delay. the best case arises when the edge is recognized just before the end of an instruction in the main program. in this best case, interrupt processing starts almost immediately. a more obscure pos- sibility would exist if there were other lower priority interrupts enabled in the system. in that case, a lower priority interrupt could initiate stacking leading to the interrupt. the priority resolution to decide which vector to take does not occur until the stacking op- erations are finished. if the ic1 edge is recognized before the condition code register (ccr) is stacked, it will be serviced rather than the lower priority interrupt that started
motorola main timer and real-time interrupt m68hc11 10-22 reference manual the interrupt process. in this unusual case, the best-case minimum response could be much shorter. this case does not arise in example 10C2 because no lower priority in- terrupts are enabled. *** initialization - (see full listing) *** c09c ce 10 00 [3] pwtop ldx #regbas point to register block c09f 86 10 [2] ldaa #%00010000 edg1b:edg1a - 0:1 c0a1 a7 21 [4] staa tctl2,x ic1 rising edges c0a3 86 ff [2] ldaa # $ff c0a5 b7 d0 06 [4] staa ic1mod ff-off; 0-lst edge; 1-last edge c0a8 7f d0 05 [6] clr ic1dun signal pulse not done c0ab 1d 23 fb [7] sclr tflg1,x $fb clear ic1f (if any) c0ae 1c 22 04 [7] bset tmsk1,x $04 enable ic1 interrupts c0b1 0e [2] cli enable interrupts c0b2 b6 d0 05 [4] waitl2 ldaa ic1dun sets after pulse done c0b5 27 fb [3] beq waitl2 loop till pulse has been timed c0b7 0f [2] sei pulse done, disable interrupts *** display results - (see full listing) *** * sv2ic1 - input capture 1 service routine * * called first when a rising edge is detected and again * when a falling edge is detected. *** c0d8 ce 10 00 [3] sv2ic1 ldx #regbas point at top of register block c0db 7c d0 06 [6] inc ic1mod $ff->0 at 1st edge; 0->1 at 2nd c0de 26 0d [3] bne no1st2 if not 0, this is trailing edge * process leading edge of pulse c0e0 ec 10 [5] ldd tic1x read time of first edge c0e2 fd d0 0d [5] std frste save till next capture * reconfigure ic1 for trailing falling edge c0e5 1d 21 30 [7] bclr tctl2,x $30 edg1b:edg1a->0:0 c0e8 1c 21 20 [7] bset tctl2,x $20 edg1b:edg1a->1:0 c0eb 20 10 [3] bra ou2ic1 done processing first edge * process trailing edge of pulse c0ed ec 10 [5] no1st2 ldd tic1,x got time of trailing edge c0ef b3 d0 0d [6] subd frste (time of last) - (time of 1st) c02f dd 01 5 [5] std hpw update result c0f5 1d 21 30 [7] bclr tctl2,x $30 disable ic1 c0f8 86 01 [2] ldaa #1 c0fa b7 d0 05 [4] staa ic1dun signal pulse measured c0fd 1d 23 fb [7] ou2ic1 bclr tflg1,x $fb clear ic1f c100 3b [12] rti ** return from ic1 service figure 10-6 measuring a pulse width with input capture
m68hc11 main timer and real-time interrupt motorola reference manual 10-23 the response time in figure 10-7 is slightly longer than it would be for a normal pro- gram because of the pseudo-vector mechanism in the evb board. the jmp instruc- tion at [3] is not shown in example 10C2 because it is actually constructed by program instructions during the initialization portion of this example program. this indirect vec- toring is done in the evb board because the vectors are located in the monitor eprom and are not accessible to an evb user. to allow use of the interrupts in an evb, the vectors were purposely pointed at specific ram locations called pseudo-vec- tors. a jmp instruction would be stored in these ram locations, which points to the start of the interrupt service routine. in a normal application, the starting address of the interrupt service routine would be hard coded into the vector locations at the top of memory. when an interrupt occurs, the user would vector directly to the service routine rather than having to execute the extra jmp instruction. (a) leading edge latency (b) process first edge, earliest opportunity for second edge figure 10-7 timing analysis for example 10C2 the bne no1st2 instruction at [5] will not branch during processing of the leading edge of the pulse being measured. execution continues with the ldd instruction in figure 10-7 (b). the bclr; bset sequence at [6] is not as fast as a simple ldaa #, staa tctl2, but the longer sequence was chosen because it does not disturb the other bits in the register. best case minimum response (17 cycles) e ic1 pin ldx #regbas interrupt response [1] [2] [4] [5] worst case minimum response (21 cycles) beq waitl2 ldaa ic1dun ldaa ic1dun beq waitl2 vect pc lhlhlhbacc yyxx evb pseudo vector jmp sv2ic1 inc ic1mod bne no1st2 [3] (12 cycles) (34 cycles) e ic1 pin bra ou2ic1 bclr tctl2,x $30 std frste [6] [7] [8] [9] ldd tic1,x bset tctl2,x $20 bclr tflg1,x $fb
motorola main timer and real-time interrupt m68hc11 10-24 reference manual the earliest place the second edge could occur and be properly handled is during the cycle after the status flag clear instruction [7], which occurs before returning from the interrupt service routine after processing the leading edge of the pulse. if the second edge came before this time, it would still be captured, but the ic1f flag would be cleared by the clearing instruction intended to clear the flag from the first edge. the minimum pulse width that can be measured by this program would be the time from [1] or [2] through [7]. this time is a total of 63 to 67 cycles or about 34 m s. this timing analysis is based on this specific example running by itself in the evb board and is not intended to show the smallest pulse that can be measured. since no other tasks are being performed in this example, the interrupt latency is somewhat shorter than it would be in a realistic system. in a normal system, the user would not have to work through the evbs pseudo-vector mechanism and would save three cy- cles of latency time (because of the jmp in the pseudo-vector locations). conversely, in a real system, the user could get this interrupt just as a multiply instruction had start- ed; thus, there could be a wait of up to 10 cycles (mul takes 10 cycles) for that instruc- tion to finish before servicing the input-capture interrupt. worse yet, the user may have just started servicing another interrupt source when the edge was recognized; thus, the input capture would have to wait for that interrupt service routine to be completed before it could be serviced. a much more detailed discussion of interrupts is presented in section 5 resets and interrupts . the shortest pulse the user would be able to measure in a realistic system will be a few hundred cycles rather than the few dozen cycles shown in this isolated example. this timing analysis is based on a detailed knowledge of timer logic and instruction tim- ing. instruction timing tells which cycle within the instruction actually reads or writes a register. instruction details can be found in appendix a instruction set de- tails . detailed information concerning timer captures is given in 10.5 timing details for the main timer system . detailed operation of the interrupt mechanism is pre- sented in section 5 resets and interrupts . 10.3.4 measuring very short time periods since the MC68HC11a8 has three input-capture functions, it is theoretically possible to measure pulse widths as short as one timer count by connecting the signal to two input-capture pins. one input capture is configured to detect the leading edge of the pulse; whereas, the other is configured to detect the trailing edge. although this func- tion is possible, it is not commonly used. 10.3.5 measuring long time periods with input capture and overflow there are at least two ways to measure time periods that are longer than the range of the 16-bit free-running timer. the following paragraphs discuss an example based on input capture and counting timer overflows, which is accurate to 1 timer count (500 ns in this case). if the user were measuring times in the seconds range to a resolution of 100 ms, a software approach might be easier than the input-capture/overflow method. in the software approach, the user sets up a real-time loop structure where the main program is executed once each tenth of a second. other real-time periods could be used, but a tenth of a second is easier. the user starts a software counter
m68hc11 main timer and real-time interrupt motorola reference manual 10-25 when the signal first changes, increments the count once each time through the main loop, and stops the count at the end of a period. this method is very simple and yields an accuracy of 100 ms, which is quite reasonable for many applications. to measure a time greater than the range of the 16-bit main timer counter with an input capture, timer overflows must be considered. a program is presented that extends the range of the timer to 24 bits by keeping track of overflows in an 8-bit software counter. by increasing the size of this software counter, the user could measure even longer periods. at 2-mhz bus speed and a divide by one prescale factor, 24 bits allow the user to measure periods up to about 8.38 s. the most difficult part of this procedure is deciding whether or not to count an overflow when a capture occurs very close to a timer overflow. given some assumptions, the user can tell if the capture happened before or after the overflow by looking at the msb of the captured value. once the user knows which happened first, the case can be treated accordingly. first, assume that all timer overflow conditions (tof= 1) will be handled before the msb of the free-running counter becomes set again (that is, in less than half the time between successive overflows). if tof and icxf are both set and the captured value has a one in its msb, then the user knows the capture occurred before the overflow. conversely, if tof and icxf are both set and the captured value is positive (msb = 0), then the capture occurred after the overflow. servicing an overflow interrupt takes less than 15 ms, even in a busy system. second, assume that if a capture and an overflow happen in the vicinity of each other, the input capture will be serviced before the overflow. vicinity means so close together that both are pending when the user reaches the input-capture service routine. the input-capture routine checks for a close overflow; therefore, if an overflow occurred just after the leading edge or just before a trailing edge of a measurement period, it can be included correctly. this assumption is needed to avoid the possibility of missing an overflow that should have been counted or to avoid counting one that occurred just outside the period being measured. again, this condition is easy to service because timer overflow is a lower priority interrupt than input captures. the only way an over- flow can be serviced before an input capture that occurred in the vicinity is if the over- flow happened enough before the input capture for the stacking and vector selection to be completed before the capture is detected. such a case, which is no different from having the overflow occur long before the capture, is treated correctly without taking any special action. example 10C3 uses input capture and counts overflows in an 8-bit software counter to allow measurement of periods between about 70 and 16,777,215 cycles (35 r s to 8.38 s). the program runs on an evb board and displays results on the evb terminal display. the important parts of the program are shown in figure 10-8 ; see 10.6 list- ing of timer examples for a complete listing. example 10C3 was specifically struc- tured to allow easy expansion to other functions. for example, two more period measurement functions can be added by adding a few instructions to the overflow ser- vice routine and basically duplicating the ic1 service routine for ic2 and ic3. the fol- lowing lines of code are from example 10C3:
motorola main timer and real-time interrupt m68hc11 10-26 reference manual c191 a6 25 [4] ldaa tflg2,x check for tof in msb c193 2a 23 [3] bpl ou3ic1 if no overflow, youre done c195 7a d0 07 [6] dec ovcnt1 this tof shouldnt count * decrement ovcnt1 to -1, tof svc routine will inc to 0 this example demonstrates the idea of indicating the tof should not count rather than directly clearing it to make it not count. although the tof is not needed for this period measurement function, it may be needed for some other function that might be in progress. although the three input-capture functions and the five output-compare functions are effectively independent of each other, they are all specifically related to the single, 16-bit, free-running counter and thus share the overflow mechanism. the capture and compare functions can independently monitor the overflow, but they should not directly interfere with its operation. *** initialization - (see full listing) *** c114 ce 10 00 [3] per24t ldx #regbas point to register block c117 86 10 [2] ldaa #%00010000 edg1b:edgia - 0:1 c119 a7 21 [4] staa tctl2,x ic1 rising edges c11b 86 ff [2] ldaa #$ff c11d b7 d0 06 [4] staa ic1mod ff-ic1 off; 0-1st edge; 1-last c120 7f d0 05 [6] clr ic1dun signal period not done c123 1d 23 fb [7] bclr tflg1,x $fb clear ic1f (if any) c126 1d 25 7f [7] bclr tflg2,x $7f clear tof (if any) c129 1c 22 04 [7] bset tmsk1,x $04 enable ic1 interrupts c12c 1c 24 80 [7] bset tmsk2,x $80 enable tof interrupts c12f 0e [2] cli enable interrupts c130 b6 d0 05 [4] waitl3 ldaa ic1dun sets after period done c133 27 fb [3] beq waitl3 loop till period has been timed c135 0f [2] sei done, disable interrupts ** display results - (see full listing) *** * sv3tof - timer overflow service routine * * called whenever any timer overflow is detected. * if the ic1 period measurement is in progress * (ic1mod positive) then the overflow counter * (upper 8-bits of period) is incremented. *** c171 7d d0 06 [6] sv3tof tst ic1mod 0 or 1, ic1 active; count tofs c174 2b 03 [3] bmi ou3tof if neg, ic1 not active c176 7c d0 07 [6] inc ovcnt1 increment ic1 overflow count c179 86 80 [2] ou3tof ldaa #$80 c17b b7 10 25 [4] staa regbas+tflg2clear overflow flag c17e 3b [12] rti ** return from tof service ** figure 10-8 measuring long periods with input capture and tof (sheet 1 of 2) ***
m68hc11 main timer and real-time interrupt motorola reference manual 10-27 * sv3ic1 - input capture 1 service routine * * called at start and end of a period being measured *** c17f ce 10 00 [3] sv3ic1 ldx #regbas point at top of register block c182 7c d0 06 [6] inc ic1mod $ff->o at 1st edge; 0->1 at 2nd c185 26 13 [3] bne no1st3 if not 0, this is second edge * process first edge of period c187 7f d0 07 [6] clr ovcnt1 zero the overflow count c18a ec 10 [5] ldd tic1,x read time of first edge c18c fd d0 08 [5] std res1 save till next capture c18f 2b 27 [3] bmi ou3ic1 if ic was before any overflow c191 a6 25 [4] ldaa tflg2,x check for tof in msb c193 2a 23 [3] bpl ou3ic1 if no overflow, youre done c195 7a d0 07 [6] dec ovcnt1 this tof shouldnt count * decrement ovcnt1 to -1, tof svc routine will inc to 0 c198 20 1e [3] bra ou3ic1 done processing first edge * process second edge of period c19a ec 10 [5] no1st3 ldd tic1,x get time of second edge c19c 2b 07 13] bmi arnov1 if msb-1, skip tof check c19e 6d 25 [6] tst tflg2,x check for overflow c1a0 2a 03 [3] bpl arnov1 if no tof, skip increment c1a2 7c d0 07 [6] inc ovcnt1 tof was before edge so count it c1a5 b3 d0 08 [6] arnov1 subd res1 (time of last) - (time of 1st) c1a8 fd d0 08 [5] std res1 update result c1ab 24 03 [3] bcc res1ok check for borrow c1ad 7a d0 07 [6] dec ovcnt1 if borrow, fix overflow count c1b0 1d 21 30 [7] res1ok bclr tctl2,x $30 disable ic1 c1b3 86 01 [2] ldaa #1 c1b5 b7 d0 05 [4] staa lc1dun signal period measured c1b8 1d 23 fb [7] ou3ic1 bclr tflg1,x $fb clear ic1f c1bb 3b [12] rti ** return from ic1 service figure 10-8 measuring long periods with input capture and tof (sheet 2 of 2) 10.3.6 establishing a relationship between software and an event in common mcu applications, a software program must generate various output con- trol signals as a result of various input signals or events. a software program monitors the input signals and produces output signals as needed. sometimes it is important for the output signals to be in some strict timing relationship to an input signal. a problem, which is called latency, arises when software requires some time to notice and re- spond to an input event. in many mcu systems, this latency determines the worst- case uncertainty in the ability of software to know exactly when an event occurred and the accuracy of the timing relationship between the event and a resulting output signal. in the MC68HC11a8, the timer system allows much more accurate control of the re- lationship between events and resulting output signals. the critical input signal will drive one of the input-capture pins of the mcu. when an event (edge) occurs on this pin, the input-capture function automatically latches the current value of the free-running timer counter. even though software takes a variable
motorola main timer and real-time interrupt m68hc11 10-28 reference manual amount of time to respond to the event, the time at which it took place was latched (re- corded), thus eliminating uncertainty due to software latency. now software can read the timer counter to determine the present timing relationship between the program and when the event occurred. better yet, an output-compare function can be set up to produce the desired output signal action at another specific value of the timer counter (i.e., at another specific time relative to the input event). since both the input event and the output action are referenced to the same timer counter, the resolution of the counter determines the worst-case uncertainty in the timing relationship. although software latency still determines the minimum controllable delay between the input event and the output action, it no longer influences the accuracy of the timing relation- ship. 10.3.7 other uses for input-capture pins at any time, software can read the logic levels on the pins used for input-capture func- tions (even if the input-capture function is enabled). these three pins may also be used as flexible interrupt input pins when the timer input-capture functions are not needed. each of these pins can be used as a separate edge-triggered interrupt with its own interrupt vector. the significant edge(s) can be individually selected by the control bits in the tctl2 register. an important advantage of these interrupt pins over the irq pin is that these interrupts can be enabled/disabled with the local interrupt en- able bits (icxi) in the tmsk1 register. another advantage of these pins is that there is a readable status indicator (icxf) so software can tell if an interrupt request is pending from these sources. software can also choose to clear any pending interrupt from one of these sources before enabling it. as with all maskable interrupt sources, interrupts can be disabled from these pins by setting the i bit in the ccr in the cpu. 10.4 output-compare functions rather than being specifically configured to perform a single function, such as vari- able-frequency square-wave generation, the output-compare functions in the MC68HC11a8 are configured and controlled by software-accessible control registers and bits so they can perform a wide variety of tasks. although some software overhead exists for some common timing functions, such as pulse-width modulation (pwm) sig- nals, these software-controlled output-compare functions are easily adaptable to a much wider range of applications than dedicated timer functions would be. there are five output-compare functions in the MC68HC11a8. each output compare has a 16-bit compare register and a dedicated 16-bit comparator. the comparator checks the free-running timer value against the 16-bit compare register during every timer count. when a match is detected, a status flag is set (ocxf), an interrupt is op- tionally generated, and timer output pins are automatically changed according to soft- ware-accessible control bits. since each of the five interrupts is separately maskable with a local interrupt enable control bit and since each has its own interrupt vector, there is no need to perform any software polling to determine the cause of an interrupt. four of the output compares operate much like the output compares on the m6801 family of mcus except that the m68hc11 has more output-compare channels and has slightly more control over the timer output pins. the fifth output compare on the
m68hc11 main timer and real-time interrupt motorola reference manual 10-29 MC68HC11a8 (oc1) can control any combination of the five timer output pins even if another output compare is already controlling the pin(s). the value and implications of this feature will be explained in greater detail. for oc[5:2], a pair of control bits in the timer control register 1 (tctl1) control the au- tomatic action that will occur at the respective timer output pin when an output com- pare happens (16-bit ocx register matches the free-running timer). the control bit pairs (omx, olx, x = 2, 3, 4, or 5) are encoded to allow the four following possibilities: 1) timer output compare causes no pin change; 2) toggle pin on each successful com- pare; 3) force pin to zero on a successful compare; and 4) force pin to one on a suc- cessful compare. each of the output compares (oc[5:2]) is associated with a separate port a pin, and the automatic pin actions for each output compare are independently controlled. for oc1, the automatic pin actions are controlled by the oc1 mask (oc1m) and oc1 data (oc1d) registers. the oc1m register specifies which port a pins are to be affect- ed by oc1. the oc1d register specifies the data to be sent to the affected port a pin(s) when there is a successful oc1 match. if oc1 and another output compare are both controlling the same pin and if both attempt to change the pin simultaneously, oc1 will have priority. output pins for the five output-compare functions can be used as general-purpose out- put pins having nothing to do with the timer system or as timer outputs directly con- trolled by the timer system. when one of these pins is configured for timer use, it cannot be written directly from software as a general-purpose port a output line. if the user needs to change a timer output pin without waiting for an actual output compare, the force output-compare function can be used. this function may be used to initialize the state of timer outputs or to force an output change before it was scheduled to occur by the associated output-compare register. another way to change the state of a timer output pin is to temporarily disengage the timer by changing the timer control registers. this method requires a more detailed understanding of the actual port a pin logic. de- tailed schematics of the port a output pins are shown and explained in section 7 parallel input/output . the 16-bit output-compare register for each output-compare function can be read or written by software as a pair of 8-bit registers. the tocx registers are forced to $ffff during reset. a write to the high-order byte of an output-compare register pair inhibits the output- compare function for one bus cycle. this inhibit prevents erroneous comparisons us- ing a 16-bit value whose high-order half was just written and whose low-order half still contains data from the previous output-compare value. consider the case where an output-compare register is $ff0f and the user tries to write it to $00ff as the free- running timer is counting through the value $000f. without the one-cycle inhibit after writing to the upper half of the output-compare register, an erroneous compare could occur at $000f. as long as the user utilizes a double-byte write instruction, such as store d (std), to update output-compare registers, this one-cycle inhibit mechanism will assure that no unintentional compares will result after the write of the high-order half but before the write of the low-order half.
motorola main timer and real-time interrupt m68hc11 10-30 reference manual as long as an output-compare function is configured to change a pin state or to gen- erate an interrupt, the action occurs every time the timer-count value matches the compare register (not just the first time a match occurs). to generate a single interrupt after some delay, read the tcnt register, add a value corresponding to the desired delay, write that value to the output-compare register, and write the appropriate con- trols to enable the interrupt. when the interrupt occurs, write the appropriate controls to disable the interrupt, or another interrupt will occur as soon as the free-running timer rolls around to the output-compare register value again. the following registers and paragraphs explain the output-compare status flags and the local interrupt enable control bits for the output-compare functions. ocxi, ocxf output compare interrupt enables and output compare flags (x= 1, 2, 3, 4, or 5) the ocxf status bit is automatically set to one each time the corresponding output- compare register matches the free-running timer. this status bit is cleared by writing to the tflg1 register with a one in the corresponding data bit position. the ocxi con- trol bit allows the user to configure each output-compare function for polled or inter- rupt-driven operation but does not affect the setting or clearing of the corresponding ocxf bit. when ocxl is zero, the corresponding output-compare interrupt is inhibited, and the output compare is operating in a polled mode. in this mode, the ocxf bit must be polled (read) by user software to determine when a match has been detected. bit 7 654321 bit 0 $1016 bit 15 bit 8 toc1 $1017 bit 7 bit 0 $1018 bit 15 bit 8 toc2 $1019 bit 7 bit 0 $101b bit 7 bit 0 $101c bit 15 bit 8 toc4 $101d bit 7 bit 0 $101e bit 15 bit 8 toc5 $101f bit 7 bit 0 tmsk1 timer interrupt mask register 1 $1022 bit 7 654321 bit 0 oc1i oc2i oc3i oc4i oc5i ic1i ic2i ic3i reset: 00000000 tflg1 timer interrupt flag register 1 $1023 bit 7 654321 bit 0 oc1f oc2f oc3f oc4f oc5f ic1f ic2f ic3f reset: 00000000
m68hc11 main timer and real-time interrupt motorola reference manual 10-31 when the ocxl control bit is one, a hardware interrupt request is generated whenever the corresponding ocxf bit is set to one. before leaving the interrupt service routine, software must clear the ocxf bit by writing to the tflg1 register (see 10.2.4 tips for clearing timer flags ). example 10C4 is a very simple program that uses an output compare to control a soft- ware time delay. for simplicity, this example uses polled mode and does not cause any automatic pin changes as the result of the output compare. the program gener- ates a 10-ms delay like the user might utilize to time an eeprom program or erase operation; however, instead of actually programming eeprom, it will just produce a pulse on an output port pin so the results can be studied on an oscilloscope. output- compare functions can also cause automatic pin changes and generate interrupt re- quests (see examples 10C5 and 10C6). a partial listing of the program for example 10C4 is shown in figure 10-9 . c1bc ce 10 00 [3] inza ldx #regbas point to register block c1bf 86 80 [2] ldaa #$80 c1c1 a7 23 [4] staa tflg1,x clear any pending oc1f flag c1c3 6f 04 [6] clr portb,x initialize port b to zeros c1c5 86 01 [2] top4a ldaa #1 top of ex10-4a c1c7 a7 04 [4] staa portb,x set lsb of port b * this is where the 10ms delay part actually starts * c1c9 ec 0e [5] ldd tcnt,x get current timer count c1cb c3 4e 20 [4] addd #20000 what will count be in 10ms? c1ce ed 16 [5] std toc1,x set oc1 to trigger then c1d0 1f 23 80 fc[7] lp1 brclr tflg1,x $80 lp1 loop here till oc1f=1 *delay is actually done here; rest is just support c1d4 1d 23 7f [7] bclr tflg1,x $7f clear oc1f c1d7 6f 04 [6] clr portb,x clear pb0 pin c1d9 18 ce 16 4e[4] ldy #5710 5710*(7~/loop) = about 20ms c1dd 18 09 [4] dlp1 dey top of software delay loop c1df 26 fc [3] bne dlp1 loop till y is zero c1e1 20 e2 [3] bra top4a repeat continuously for o-scope figure 10-9 simple output-compare example this example is only intended to show the most basic use of an output-compare func- tion. it is not intended to be an especially efficient way to delay a fixed period of time. the following three instructions are a simpler way to delay if no other tasks are to be performed during the delay: c1d9 18 ce 16 4e[4] ldy #5710 5710*(7~/loop)= about 2oms c1dd 18 09 [4] dlp1 dey top of software delay loop c1df 26 fc [3] bne dlp1 loop till y is zero by contrast, an output compare in interrupt-driven mode has the advantage of allowing
motorola main timer and real-time interrupt m68hc11 10-32 reference manual the user to perform other tasks while waiting for the delay. 10.4.1 normal i/o pin control using oc[5:2] the user can independently program the automatic pin actions to occur for each out- put-compare function. for oc[5:2], a pair of control bits (omx, olx) in tctl1 are used to control the automatic pin actions. omx, olx output compare pin control (x = 1, 2, 3, 4, or 5) this pair of bits determines the automatic actions that occur on the port a timer output pin when there is a successful output compare. each oc[5:2] function corresponds to a specific pin of port a. each pair of bits controls the action for the corresponding out- put-compare function. these bit pairs are encoded as shown in the following table: example 10C5 uses oc2 to generate a square wave at the pa6/oc2 pin. the program runs on an evb board, and the results are monitored with an oscilloscope. before run- ning this program, manually set the half-cycle delay time (as a number of cycles) in the double-byte location hdly ($d000,d001). for example, if $01,00 is stored at $d000,d001, a square wave with a period of 256 m s would be generated (half period = 256 cycles x 500 ns/cyc). figure 10-10 shows the program for example 10C5. the initialization of the pseudo-vector at the top of example 10C5 is done for the evb board and would not be a normal part of a practical application. the three cycles need- ed for the extra jmp instruction are shown at [3] in figure 10-11 . tctl1 timer control register 1 $1020 bit 7 654321 bit 0 om2 ol2 om3 ol3 om4 ol4 om5 ol5 reset: 00000000 omx olx configuration 0 0 ocx does not affect pin (oc1 still may) 0 1 toggle ocx pin on successful compare 1 0 clear ocx pin on successful compare 1 1 set ocx pin on successful compare
m68hc11 main timer and real-time interrupt motorola reference manual 10-33 c1e3 8e 00 47 [3] top5 lds #$0047 top of users stack area on evb c1e6 86 7e [2] ldaa #$7e jump (extended) opcode c1e8 97 dc [3] staa pvoc2 pseudo vector see manual text c1ea ce c1 fd [3] ldx #sv5oc2 address of oc2 service routine c1ed df dd [4] stx pvoc2+1 finish jump instruc to tof svc c1ef ce 10 00 [3] ldx #regbas point to register block c1f2 86 40 [2] ldaa #%01000000 om2:ol2 = 0:1 c1f4 a7 20 [4] staa tctl1,x set oc2 for toggle, on compare c1f6 a7 23 [4] staa tflg1,x clear any pending,oc2f c1f8 a7 22 [4] staa tmsk1,x enable oc2 interrupts c1fa 0e [2] cli enable interrupts c1fb 20 fe [3] bra * interrupt driven; sit here *** * sv5oc2 - output compare 2 service routine * * called at each oc2 interrupt. *** c1fd fc d0 00 [5] sv5oc2 ldd hdly get delay time for 1/2 cycle c200 e3 18 [6] addd toc2,x add to last compare value c202 ed 18 [5] std toc2,x update oc2 (schedule next edge) c204 1d 23 bf [7] bclr tflg1,x $bf clear oc2f c207 3b [12] rti ** return from oc2 service ** figure 10-10 generating a square wave with output compare
motorola main timer and real-time interrupt m68hc11 10-34 reference manual figure 10-11 timing analysis for example 10C5 figure 10-11 shows a detailed timing analysis for example 10C5. this degree of detail is not normally needed, but this analysis shows exactly what occurs during an interrupt driven output compare. the timer count has a fixed relationship to real time; whereas, software can be aligned to the timer count in any of several ways. it is generally not known (nor does it need to be) which of these several possible relationships is correct. although software latencies do not affect the accuracy with which output edges are placed, these latencies do determine the shortest possible delay between successive output edges. in this isolated example, the software latencies are quite short, but in a practical application, latencies from other interrupt sources must be considered. this timing analysis shows the case where the half-period delay (hdly) is 54 cycles, and the oc2f was set just before the bra * finished [1]. this analysis represents the fastest response to the oc2f bit. the flag is actually set [1] just before the pin state changes. the exact timing of the flag and pin changes is discussed in detail in 10.5 timing details for the main timer system . the period can be set as short as 52 cycles (the total time needed to service each interrupt from [1] to [8]). this example is intended to show a way to produce a simple square wave and is not intended to be the most efficient way to perform this task. (28 cycles) e interrupt response [1] [4] [5] vect pc lhlhlhbacc yyxx evb pseudo vector jmp sv5oc2 ldd hdly [3] oc2 pin [2] bra * addd toc2,x oc2f (26 cycles) e interrupt response [7] [9] pc lhlhlhb yyxx [8] oc2 pin bra * std toc2,x bclr tflg1,x $bf oc2f pc l hl hl h b a cc y y x x rti [6]
m68hc11 main timer and real-time interrupt motorola reference manual 10-35 10.4.2 advanced i/o pin control using oc1 one of the five output-compare functions (oc1) in the MC68HC11a8 has special timer output pin controls that were not present on any previous motorola mcus. these new controls allow this output-compare function to simultaneously control the states of up to five output pins. this output compare can also be configured to control a pin or pins that are also being controlled by one of the other four output-compare functions. oc1 uses the oc1m and the oc1d to control the automatic timer output pin actions occurring as a result of a match between the oc1 register and the free-running timer. each of the five msbs of these registers corresponds bit-for-bit with a port a output pin. the three remaining low-order bits of these registers are not used and always read as zeros. for each port a output pin to be affected by oc1, the user would set the cor- responding bit of oc1m. when a successful oc1 compare occurs, each port a pin to be affected (indicated by the corresponding bit of oc1m set) will assume the value of the corresponding bit of oc1d. values of bits in oc1d corresponding to zeros in the oc1m register are dont cares. usually, the user only has to write to the oc1m register once to establish which pins will be controlled by oc1. the relationship between reg- ister bits and port a pins is provided in the reference below the following registers: oc1 can only affect the pa7 pin if the pin is configured as an output as opposed to its default configuration as an input. to configure pa7 as an output, the data direction control bit for port a bit 7 (ddra7) in the pulse accumulator control register (pactl) must be set to one. 10.4.2.1 one output compare controlling up to five pins the special pin control mechanisms on oc1 allow it to simultaneously control as many as five timer output pins. (software can be used to allow any single output compare to control multiple outputs, but software latency will affect the resolution and the ability to repeat timed actions accurately.) the oc1 mechanism allows pins to be controlled with a timing accuracy equal to one count of the timer counter. the ability to control multiple outputs with a single output-compare channel is espe- cially useful where the outputs are all associated with a single external device for example, the signals driving a stepper motor. in such a case, it is always possible to know the required state for all of the outputs whenever any one is going to change. on oc1m output compare 1 mask $100c bit 7 654321 bit 0 oc1m7 oc1m6 oc1m5 oc1m4 oc1m3 0 0 0 reset: 00000000 oc1d output compare 1 data $100d bit 7 6 5 4 3 2 1 bit 0 oc1d7 oc1d6 oc1d5 oc1d4 oc1d3 0 0 0 reset: 0 0 0 0 0 0 0 0 references: pa7/pa1 pa6/oc2 pa5/oc3 pa4/oc4 pa3/oc5 pa2/ic1 pa1/ic2 pa0/ic3
motorola main timer and real-time interrupt m68hc11 10-36 reference manual the other hand, if the outputs control unrelated devices, it might be more practical to use separate output-compare channels for each output. a side benefit to using oc1 to control several timer outputs is that the other output- compare functions associated with these pins become available for general-purpose software timing functions that do not directly control pins. 10.4.2.2 two output compares controlling one pin oc1 can also be used in conjunction with one or more other output compares to achieve even more timing flexibility. oc1 can control a timer output even when one of the other output compares is already controlling the same pin, which allows the pro- grammer to schedule two succeeding edges of each output signal at a time. this ca- pability reduces software overhead because only one of the two output compares needs to generate an interrupt. pulses as short as one e cycle, which are accurately positioned with one-cycle resolution (500-ns resolution), can be generated. example 10C6 uses oc1, oc2, and oc3 together to produce two pwm outputs. this particular program can produce active-high pwm signals with a minimum period of 200 cycles (100 m s or 10 khz) and a duty cycle of 0 to 100 percent. actually, the pro- gram only produces duty cycles of 50 to 100 percent. when a smaller duty cycle is specified, it is automatically changed to 100 percent minus the specified duty cycle, and the polarity of the output is switched. (a 30-percent active-high duty cycle is the same as a 70-percent active-low duty cycle.) figure 10-12 shows the important parts of the program for example 10C6. before running this example program on the evb board, the period and duty cycle are established manually with memory modify commands. period is set indirectly by set- ting the location pwmp1p at $d002. this value is one percent of the period (in cycles); thus, a value of $02 sets the period to 200 cycles. when the program starts, this value is multiplied by 100 and stored to location pwmper. program latencies are such that a period of 100 cycles (pwmp1p = $01) is too short, and the program will not operate correctly. duty cycles are stored as percentages at locations pwmdc1 and pwmdc2 ($d003 and $d004, respectively; $64 = 100 percent).
m68hc11 main timer and real-time interrupt motorola reference manual 10-37 *** initialization - (see full listing) *** c217 86 50 [2] ldaa #%0l010000 omx:olx = 0:1 for toggle c219 a7 20 [4] staa tctl1,x oc2 and oc3 for toggle c21b 86 70 [2] ldaa #%01110000 oclm6,5, & 4 - 1 c21d a7 0c [4] staa ocim,x control oc2/pa6, oc3/pa5, & pa4 c21f 5f [2] clrb build oc1d initial value in b c220 b6 d0 03 [4] ldaa pwmdc1 check for oc2 duty > or = 50% c223 81 32 [2] cmpa #50 if <50% oc1 drives low... c225 23 02 [3] bls arnz61 and oc2 toggles high. c227 cb 40 [2] addb #%01000000 else oc1 driv high/oc2 tog low c229 b6 d0 04 [4] arnz61 ldaa pwmdc2 check for oc3 duty > or = 50% c22c 81 32 [2] cmpa #50 if <50% oc1 drives low... c22e 23 02 [3] bls arnz62 and oc3 toggles high. c230 cb 20 [2] addb #%00100000 else oc1 driv high/oc3 tog low c232 e7 0d [4] arnz62 stab oc1d,x store starting value for oc1d * calculate period & duty cycle as cycle count offsets c234 b6 d0 02 [4] ldaa pwmp1p 1% of period c237 c6 64 [2] ldab #100 c239 3d [10] mul 100 * pwmp1p = pwmper c23a fd d0 1f [5] std pwmper store period c23d ed 16 [5] std toc1,x start with tcnt = pwmper c23f b6 d0 03 [4] ldaa pwmdc1 calculate offset for oc2 c242 8d 12 [6] bsr caloff adj duty and calc offset c244 ed 18 [5] std toc2,x schedule first oc2 toggle c246 b6 d0 04 [4] ldaa pwmdc2 calculate offset for oc3 c249 0d 0b [6] bsr caloff adj duty and calc offset c24b ed 1a [5] std toc3,x schedule first oc3 toggle c24d 86 80 [2] ldaa #$80 finish initialization c24f a7 23 [4] staa tflg1,x clear any old oc1 flag c251 a7 22 [4] staa tmsk1,x enable oc1 interrupt c253 0e [2] cli c254 20 fe [3] bra * pwms driven by oc1 interrupts *** * sv6oc1 - output compare 1 service routine *** c269 ce 10 00 [3] sv6oci ldx #regbas point to register block c26c a6 0d [4] ldaa oc1d,x change state of pa4 at next oc1 c26e 88 10 [2] eora #%00010000 inverts ocld4 (pa4 pin control) c270 a7 0d [4] staa oc1d,x update oc1 automatic pattern c272 0c 18 [5] ldd toc2,x get last oc2 compare value c274 f3 d0 1f [6] addd pwmper add count equiv to period c277 ed 18 [5] std toc2,x update oc2 (schedule next oc2) c279 ec 1a [5] ldd toc3,x get last oc3 compare value c27b f3 d0 1f [6] addd pwmper add count equiv to period c27e ed 1a [5] std toc3,x update oc3 (schedule next oc3) c280 ec 16 [5] ldd toc1,x get last oc1 compare value c282 f3 d0 1f [6] addd pwmper add count equiv to period c285 ed 16 [5] std toc1,x update oc1 (schedule next ocl) c287 1d 23 7f [7] bclr tflg1,x $7f clear oc1f c28a 3b [12] rti ** return from oc1 service ** figure 10-12 producing two pwm outputs with oc1, oc2, and oc3 the larger upper portion of this program is executed only once to set up and to start the pwm outputs. after this initial setup, the pwm signals are free running and are controlled by oc1 interrupts only. when an oc1 interrupt occurs, a value equal to the period is added to each of the output-compare registers (toc1, toc2, and toc3). when this oc1 service routine is enabled, the pwm outputs will have been forced to their active level by the oc1 match that requested the interrupt. when this service rou- tine is done, oc1 is set to start the next pwm period; oc2 and oc3 are set to termi- nate the current pwm pulse. the pwm pulses, which are known to be at least 50
motorola main timer and real-time interrupt m68hc11 10-38 reference manual percent of the period, control how quickly the oc1 service routine must finish (oc2 and oc3 must be scheduled in time to occur as early as 50 percent of the way to the next pwm pulse start). the oc1 interrupt service takes almost 100 cycles, but oc2 and oc3 are updated somewhat before the end of the routine. thus, the theoretical minimum period is about 140 cycles (two times 70 cycles, where 70 cycles is the ap- proximate latency time from an oc1 interrupt request to when oc2 and oc3 have been updated). because the example was set up so that period is specified by the number of cycles in one percent of the period, a value of two makes period equal 200 cycles, which is acceptable; whereas, a value of one makes period equal 100 cycles, which is too small. this example is only one of many ways to generate pwm signals in the m68hc11. example 10C7 demonstrates an alternate way, which uses only one output compare. the approach used in that example does not allow the duty cycle to be too close to 0 or 100 percent because there is a minimum latency requirement between any two suc- cessive edges on the pwm output signal. in general, any approach will be subject to some unique set of limitations. as with many engineering problems, there is no single best solution; the user will have to select the best method based on all the application requirements. 10.4.3 forced output compares the output-compare force mechanism provides a convenient way to change timer out- put pin states without actually setting up and waiting for an output-compare match. the force mechanism is useful to force an initial state at the start of a timing sequence or to force an output compare earlier than it was scheduled. consider the case where the user has scheduled an output compare to occur at a certain time, but as the time approaches, the user decides instead the compare should occur as soon as possible. (this case is an actual situation that arises in spark timing control in some automotive engine control applications.) in the older m6801 family mcu, the user had to read the timer counter, add a small value to it corresponding to a software delay, and write this value to the output-compare register so that a compare match would occur at the next e-clock cycle after the compare register update. with the force mechanism in the m68hc11 family, the user writes to the cforc register to force any combination of output-compare channels to trigger. to use the output-compare force mechanism, the user would write to the cforc reg- ister with ones in the bit positions corresponding to the output-compare channels to be forced. writing a zero to a bit in the cforc register has no effect on the correspond- ing output-compare channel. at the next timer count after the write to cforc, the forced channels will trigger their programmed pin actions to occur. the forced actions are synchronized to the timer counter clock, which is slower than e if a prescale factor has been specified (pr1, pr0). as shown in figure 10-1 , the output-compare force signal causes pin action but does not affect the ocxf bit nor generate interrupts. normally, the force mechanism would not be used in conjunction with the automatic pin action that toggles the corresponding output-compare pin. consider the case pre- viously described where a force is being used to trigger the pin action earlier than it was scheduled to occur. the user might easily fall into the trap of forcing a toggle just
m68hc11 main timer and real-time interrupt motorola reference manual 10-39 before the output-compare match was about to occur. the force mechanism would toggle the pin once, and as soon as the match occurs, the pin would toggle again, which is almost certainly not what the user would want to happen. in the same situa- tion, if the automatic pin action was programmed to set the pin high or clear the pin low, an actual match just after a force mechanism would order the pin to change to the state it is already in (same effect as doing nothing). the following register and bit descriptions explain the output-compare force register (cforc). focx force output compare (x = 1, 2, 3, 4, or 5) these bits may be used to force an output compare rather than waiting for a match between the output-compare register and the free-running counter. the automatic pin actions programmed for the output compare happen as if a match had occurred, but no interrupt is generated (ocxf is not set). to force one or more output-compare channels, write to the cforc register with ones in the bit positions corresponding to the channels to be forced. the logic-high state of these bits is transitory, and the cforc register will never be read as anything other than zero. the force mechanism is synchronized to the timer counter clock. as many as 16 e-clock cycles could occur between the write to cforc and the compare force if the largest prescale factor is set for the timer system (pr1, pr0 = 1:1 to ? 16). 10.5 timing details for the main timer system the detailed timing information presented is much more detailed than most users will ever need, but it is given to provide additional insight into the operation of the mcu. figure 10-13 shows the details concerning the timer counter as the mcu leaves reset. during reset, the counter is forced to $ffff and does not count. as the internal reset signal is released, the counter begins to count just before the reset vector appears on the address bus. although figure 10-13 shows the reset vector to be $fffe,ffff, the timing details would be the same if the processor is reset in any mode, including test and bootstrap modes where the reset vector would be $bffe,bfff. the timer overflow logic is inhibited so that this first $ffffC$0000 transition does not register as an overflow. cforc timer compare force $100b bit 7 654321 bit 0 foc1 foc2 foc3 foc4 foc5 0 0 0 reset: 00000000
motorola main timer and real-time interrupt m68hc11 10-40 reference manual figure 10-13 timer counter as mcu leaves reset figure 10-14 shows timing details for a read of tcnt. the address and data buses shown in figure 10-14 are internal buses and have different timing than the more fa- miliar external buses. these internal buses were used because it is much more difficult to understand what is occurring from the external address and data buses. figure 10-14 timer counter read cycle-by-cycle analysis figure 10-14 shows a cycle-by-cycle view of these internal buses for a double-byte read instruction (ldd tcnt). when the upper byte of tcnt is read in the fourth cycle of the ldd instruction, the current value of the timer i sn+3.the low-order half of the timer is passed through a normally transparent latch. this latch is frozen for one cycle after every high-byte read of tcnt so that a double-byte read can read the low-order e address bus ph2 timer count vector fetch fffe fffe vector vector+ 1 ffff ffff 0000 0001 0002 0003 first user instruction? ? ? sequence is the same for any reset (external, cop, or clock monitor) and any mode (normal or special). fffe * ffff * * ph2 address bus (internal) e timer count ldd tcnt read timer count (extended addr mode) nn+2 n+1 n+3 n+4 n+5 opcode addr operand (lo) operand (hi) $100f/tcnt(lo) next opcode data bus (internal) lo(n+ 3) hi(n+ 3) $0e $10 opcode $100e/tcnt(hi) fetch opcode fetch 16-bit operand address read high byte of tcnt read low byte of tcnt
m68hc11 main timer and real-time interrupt motorola reference manual 10-41 half that belongs with the same count state as the upper half just read. even though the counter has actually advanced t on+4bythe last cycle of this ldd instruction, the value read will be the lower half of count n + 3. the information in figure 10-13 and figure 10-14 can be combined to find the value that would be returned if the ldd instruction was performed as the first instruction after reset that is, if the reset vector pointed directly to the ldd instruction. the value read will always be $0005. the prescaler is built around a divided by 16 counter. when a new value is written to the prescaler control bits (pr1, pr0) in the tmsk2 register, the clocking rate to the main timer changes to the new rate at the next $fC$0 transition of this internal 4-bit prescaler counter. figure 10-15 shows timing details for an input capture. input-capture timing is not af- fected by a prescale factor; thus, this figure only shows the divided by one case. this figure also only shows the case where the input-capture function is configured to de- tect a rising edge. again, the polarity of the edge is not important to the timing. the normal sequence of events in an input capture is as follows: 1. asynchronously detect an edge at the icx pin. 2. set the icxf bit at the next falling edge of the internal ph2 clock. 3. transfer the current timer count to the 16-bit ticx register during the next ph2 logic high. figure 10-15 input-capture timing details if the cycle at [4] happens to be a high-byte read of the tlcx register (which would be unusual), the transfer at [3] will be delayed until [6] so the transfer will not corrupt a double-byte read at cycles [4] and [5]. figure 10-16 shows two timing situations related to output compares. a normal com- pare match is shown at [1]; a compare inhibit situation is shown at [4]. ph2 icxf e timer count n 1 n + 1 n n+2 n+3 n+4 icx pin read ticx (hi) read ticx (lo) [4] [5] [1] [2] [3] [6]
motorola main timer and real-time interrupt m68hc11 10-42 reference manual in the normal compare match situation, the timer count is compared to the value in a tocx register during ph2 high. timer counting occurs at the falling edges of ph2 to prevent interference between counting and comparisons. ph2 is an internal clock that leads e by 90 . when the match is detected [1], ocxf is set at the falling edge ph2 where the match was true. the pin-state change (if any) is delayed by another quarter cycle so changes will occur at the falling edge of the e clock. if there were a prescale factor, the compare true would occur during the first ph2 cycle where the count matched the tocx value. additional matches would be inhibited until the next timer clock or until tocx is written. this inhibit mechanism protects against multiple com- pare matches during a prescaled timer count (the tocx register actually matches the timer count for several ph2 cycles when there is a prescale factor). in the unlikely case of a big prescale factor (e.g., ? 16) and a match at the start of count $nnnn, if the user wrote $nnnn to the tocx register while the count was still $nnnn, the output-compare actions would be retriggered. figure 10-16 output-compare timing details at [4] in figure 10-16 , the one-cycle compare inhibit results from a write to tocx dur- ing cycle [3]. this inhibit mechanism prevents an erroneous compare during the write to the low-order half of tocx. if the output compare were not inhibited here, the tocx register would contain an erroneous value composed of the new high byte written at [3] and the low byte from the former value in tocx. this inhibit mechanism is separate from the compare mechanism discussed in the previous paragraph. 10.6 listing of timer examples the following listing is a composite of timer section examples 10C1 through 10C7. since many of the references and equates are common for all the examples, it saves space to group them. all the examples can be assembled and loaded into an evb board for evaluation at the same time. in general, the user must set up some initial sig- nals and variables, and then execute an evb "go" command to start each example routine. timer count n 1 n + 1 n n+2 n+3 n+4 ph2 e write tocx (hi) write tocx (lo) ocx pin [3] [1] ocxf [2] compare enable match [4] previous pin state new pin state
m68hc11 main timer and real-time interrupt motorola reference manual 10-43 listing - timer examples sheet 1 of 16 ***** * this listing contains all examples for reference manual section 10 ***** * timer example 10C1 ** equates registers will be addressed with ind,x mode * 1000 regbas equ $1000 starting address for register block 0004 portb equ $04 output port b 000c oc1m equ $0c oclm7,oclm6,oclm5,oclm4;oclm3,-,-,- 000d oc1d equ $0d ocld7,ocld6,ocld5,ocld4;ocld3,-,-,- 000e tcnt equ $0e free running counter (16 bit) 0010 tic1 equ $10 ic1 register (16 bit) 0016 toc1 equ $16 oc1 register (16 bit) 0018 toc2 equ $18 oc2 register (16 bit) 001a toc3 equ $1a oc3 register (16 bit) 0020 tctl1 equ $20 om2,ol2,om3,ol3;om4,ol4,om5,ol5 0021 tctl2 equ $21 -,-,edglb,edg- la;edg2b,edg2a,edg3b,edg3a 0022 tmsk1 equ $22 oc1i,oc2i,oc3i,oc4i;oc51,ic1i,ic2i,ic3i 0023 tflg1 equ $23 oc1f,oc2f,oc3f,oc4f;oc5f,ic1f,ic2f,ic3f 0024 tmsk2 equ $24 toi,rtii,paovi,paii;-,-,pr1,pr0 0025 tflg2 equ $25 tof,rtif,paovf,paif;-,-,-,- *** evb routine addresses & pseudo vector equates ffb8 .outa equ $ffb8 print character in a-reg ffc4 .outcrl equ $ffc4 output ffca .outsto equ $ffca output msg seg (no ) ffc7 .outstr equ $ffc7 output msg w/leading 00e8 pvic1 equ $00e8 evb pseudo vector for ic1 00d0 pvtof equ $00d0 evb pseudo vector for tof 00dc pvoc2 equ $00dc evb pseudo vector for oc2 00df pvoc1 equ $00df evb pseudo vector for oc1 *** ram variable assignments d000 org $d000 start variables in evb ram (upper half) d000 hdly rmb 2 half-cycle delay (in 0.5 m s incre- ments) d002 pwmp1p rmb 1 1% of pwm period (1 to 256 cyc) ex 10- 7 d003 pwmdc1 rmb 1 duty cycle for pwm signal at oc2 pin d004 pwmdc2 rmb 1 duty cycle for pwm signal at oc3 pin d005 ic1dun rmb 1 flag: 0-not done,l-pulse measured d006 ic1mod rmb 1 s/w mode flag: ff-off,0-1st,1-last edge d007 ovcnt1 rmb 1 overflow cnt (upper 8 bits of result) d008 res1 rmb 2 pulse width in cycles (16 bits) d00a htemp rmb 3 temp for h6tod8 (3 bytes) d00d frste rmb 2 time of first edge (16 bits) d00f perc rmb 2 period in cycles (16 bits) d011 temp1 rmb 2 temp for conversion (16 bits)
motorola main timer and real-time interrupt m68hc11 10-44 reference manual d013 freqh rmb 2 freq in hex (16 bits) d015 hpw rmb 2 pulse width (16 bits hex) d017 dbufr rmb 8 decimal result buffer (8 bytes ascii) * some routines use only first 5 bytes of dbufr d01f pwmper rmb 2 period of pwm signals in (cycles) d021 offhi rmb 2 oc2 high offset (calculated) d023 offid rmb 2 oc2 low offset (calculated)
m68hc11 main timer and real-time interrupt motorola reference manual 10-45 listing - timer examples sheet 2 of 16 c000 org $c000 prog starts in evb ram at $c000 * timer example 10C1 (a) measuring period with input capture * * uses polling rather than interrupts. * measures period between two rising edges at ic1 pin * overflows not considered so max period is 65,535 cyc * min period measurable with this program is about 27 cyc * * this program runs on an evb board and displays results * on the evb terminal display. *** opt c c000 8e 00 47 [3] pertop lds # $0047 top of users stack area on evb c003 ce 10 00 [3] ldx #regbas point to register block c006 86 10 [2] ldaa #%00010000 c008 a7 21 [4] staa tctl2,x edglb:edgla - 0:1, rising edges c00a 86 04 [2] ldaa # $04 c00c a7 23 [4] staa tflg1,x clear any old oc1 flag * ready to detect first rising edge c00e 1f 23 04 fc[7] brclr tflg1,x $04 * loop here until edge * first edge detected c012 ec 10 [5] ldd tic1,x read time of first edge c014 fd d0 0d [5] std frste save first capture value c017 86 04 [2] ldaa # $04 c019 a7 23 [4] staa tflg1,x clear ic1f before next edge * ready to capture time of second edge c01b 1f 23 04 fc[7] brclr tflg1,x $04 * loop here until edge * second edge detected c01f ec 10 [5] ldd tic1,x read time of second edge c021 b3 d0 0d [6] subd frste 2nd - lst -> d c024 fd d0 0f [5] std perc save result (period in cycs) * the period of the signal at pa2/ic1 pin has been * measured and the time is stored at perc as a 16-bit * hex number representing the number of cpu bus cycles * that elapsed between two rising edges * timer example 10C1 (b) changing period to frequency * * the period found in example 10-la is expressed as a number * of bus cycles (@e-2mhz, 1 bus cycle=0.5 m s) and it is * currently in the d-reg and at perc. values < or = $20 * will be considered too small (freq too high) to be * accurately measured with this program and will be trapped * out to make the period to frequency conversion program easier. * $0021 corresponds to 60,606 hz, $ffff is 30.5 hz. ***
motorola main timer and real-time interrupt m68hc11 10-46 reference manual listing timer examples sheet 3 of 16 c027 fe d0 0f [5] ldx perc period in cycles (16 bits) c02a 1a 83 00 20[5] cpd #32 ($20) check against min allowed c02e 22 03 [3] bhi okp skip if ok c030 7e c0 88 [3] jmp outrng else go say it was too small c033 cc 00 20 [3] okp ldd #32 x-period; d-32 c036 03 [41] fdiv d/x -> x; r -> d c037 ff d0 11 [5] stx temp1 * (freq*16)+1,000,000; radix left of msb * * we now have frequency but it isnt in a good displayable * form yet. if we move the binary radix 16 places to the right * we would have a 16-bit integer representing * e(2**20)/(10**6) x freq] or [((1,048,576)/(1,000,000))*freq). * by adding and subtracting binary multiples of the freq we * will arrive at [((1,000,000)/(1,000,000))*freq] (or just frequency) * * 1,048,576 16-bit starting value ((2**20)freq)+(10**6) * - 32,768 2**15 * - 16,384 2**14 * + 512 2**9 * + 64 2**6 * = 1,000,000 * freq * * the limitation of 33 ($21) cycles min was selected so * (1,048,576/1,000,000)*freq would fit in 16 bits so we would * only need 1 fdiv, although it is pretty easy to extend the * precision of an fdiv * * the partial results which are added and subtracted in this * program may have an error of lsb ea. because i truncated * rather than rounding. * c03a fc d0 11 [5] ldd temp1 (2**20)f; where f=freq+(10**6) c03d 04 [3] lsrd c03e 04 [3] lsrd c03f 04 [3] lsrd a=(2**9)f; d=(2**17)f c040 7f d0 13 [6] clr freqh clr upper half of hex freq loc. c043 b7 d0 14 [4] staa freqh+1 freqh is a temp = 512f c046 04 [3] lsrd c047 04 [3] lsrd now d=(2**15)f or 32,768f c048 fd d0 11 [5] std temp1 needs to be in mem for subtract c04b 8f [3] xgdx d=(2**20)f; x=(2**15)f c04c b3 d0 11 [6] subd temp1 1st subtraction (-32k) c04f 8f [3] xgdx working result -> x; d=(2**15)f c050 04 [3] lsrd a=(2**6)f; d=(2**14)f c051 fd d0 11 [5] std temp1 put in mem so you can subtract c054 bb d0 14 [4] adda freqh+1 (512+64)f c057 b7 d0 14 [4] staa freqh+1 update low half of freqh c05a 8f [3] xgdx d=1,015,808*f; x=junk c05b b3 d0 11 [6] subd temp1 999,424*f c05e f3 d0 13 [6] addd freqh 1,000,000*f = frequency c061 fd d0 13 [5] std freqh save the 16-bit binary result
m68hc11 main timer and real-time interrupt motorola reference manual 10-47 listing timer examples sheet 4 of 16 * since most of us dont think in hexadecimal, lets * change to decimal before printing. the subroutine * (htodp) is shown at the end of this listing. * * the display will look like... * *ppppp cyc fffff hz --- or like--- *freq. is too high * * where ppppp is period in cycles & fffff is freq. * (decimal) * * evb subroutines will be used and when done we will * jump back to the beginning and repeat continuously. * c064 bd ff c4 [6] jsr .outcrl print a c067 ce d0 0f [3] ldx #perc point at hex period c06a bd c3 33 [6] jsr htod convert to 5 digit decimal c06d bd c2 df [6] jsr p5dec print 5 digit decimal c070 ce c3 d3 [3] ldx #msgcyc point at cycles c073 bd ff ca [6] jsr .outsto print message segment c076 ce d0 13 [3] ldx #freqh point at hex frequency c079 bd c3 33 [6] jsr htod convert to 5 digit decimal c07c bd c2 df [6] jsr p5dec print 5 digit decimal c07f ce c3 e0 [3] ldx #msghz point at hz c082 bd ff ca [6] jsr .outsto print message segment c085 7e c0 00 [3] jtop jmp pertop to top & measure another period c088 ce c3 e4 [3] outrng ldx #msger1 point at "freq. is too high" c08b bd ff c7 [6] jsr .outstr print msg w/leading c08e 20 f5 [3] bra jtop to top & measure another period * ********* end ex 10-1b *** * timer example 10-2 measuring pulses with input capture * * uses interrupts. * measures time between a rising edge and a falling edge * (period of a positive pulse) at the ic1 pin. * overflows not considered so max is 65,536 cyc * min time measurable with this program is about __ cyc * * this program rune on an evb board and displays results * on the evb terminal display. *** * initialization portion * c090 8e 00 47 [3] pwinz lds # $0047 top of users stack area on evb c093 86 7e [2] ldaa # $7e jump (extended) opcode c095 97 e8 [3] staa pvic1 ic1 pseudo vector c097 ce c0 d8 [3] ldx #sv2ic1 address of ic1 service routine c09a df e9 [4] stx pvic1+1 finish jmp inst to ic1 routine
motorola main timer and real-time interrupt m68hc11 10-48 reference manual listing - timer examples sheet 5 of 16 * main program portion of pulse width program * c09c ce 10 00 [3] pwtop ldx #regbas point to register block c09f 86 10 [2] ldaa #%00010000 top of main for pw24 prog c0a1 a7 21 [4] staa tctl2,x edg1b:edg1a=0:l ic1 rising edge c0a3 86 ff [2] ldaa # $ff c0a5 b7 d0 06 [4] staa ic1mod ff-ic1 off; 0-lst; 1-last edge c0a8 7f d0 05 [6] clr ic1dun signal pulse not done c0ab 1d 23 fb [7] bclr tflg1,x $fb clear ic1f (if any) c0ae 1c 22 04 [7] bset tmsk1,x $04 enable ic1 interrupts c0b1 0e [2] cli enable interrupts c0b2 b6 d0 05 [4] waitl2 ldaa ic1dun sets after pulse done c0b5 27 fb [3] beq waitl2 loop till pulse has been timed c0b7 0f [2] sei pulse done, disable interrupts * display pulse width as xx,xxx ms (32,768 max) c0b8 bd ff c4 [6] jsr .outcrl begin printing result c0bb fc d0 15 [5] ldd hpw number of cyc (0.5 m s/cyc) c0be 04 [3] lsrd 16-bit +2 to change to m s c0bf 24 03 [3] bcc arnup2 ? need to round result ? c0c1 c3 00 01 [4] addd #1 yes; round up c0c4 fd d0 15 [5] arnup2 std hpw update hex pulse width c0c7 ce d0 15 [3] ldx #hpw point at hex pulse width c0ca bd c3 33 [6] jsr htod convert to 5 digit decimal c0cd bd c2 df [6] jsr p5dec print 5 digit decimal c0d0 ce c3 f6 [3] ldx #msgms point at rest of display line c0d3 bd ff ca [6] jsr .outsto print milliseconds c0d6 20 c4 [3] bra pwtop goto top of main & repeat * * end of main program portion *** * sv2ic1 - input capture 1 service routine * * called first when a rising edge is detected and again * when a falling edge is detected. *** c0d8 ce 10 00 [3] sv2ic1 ldx #regbas point at top of register block c0db 7c d0 06 [6] inc ic1mod $ff->0 at 1st edge; 0->1 at 2nd c0de 26 0d [3] bne no1st2 if not 0, this is trailing edge * process leading edge of pulse c0e0 ec 10 [5] ldd tic1,x read time of first edge c0e2 fd d0 0d [5] std frste save till next capture * reconfigure ic1 for trailing falling edge c0e5 1d 21 30 [7] bclr tctl2,x $30 edg1b:edg1a->0:0 c0e8 1c 21 20 [7] bset tctl2,x $20 edg1b:edg1a->1:0 c0eb 20 10 [3] bra ou2ic1 done processing first edge * process trailing edge of pulse c0ed ec 10 [5] no1st2 ldd tic1,x get time of trailing edge c0ef b3 d0 0d [6] subd frste time of last minus time of 1st c0f2 fd d0 15 [5] std hpw update result c0f5 1d 21 30 [7] bclr tctl2,x $30 disable ic1 c0f8 86 01 [2] ldaa #1 c0fa b7 d0 05 [4] staa ic1dun signal pulse measured c0fd 1d 23 fb [7] ou2ic1 bclr tflg1,x $fb clear ic1f c100 3b [12] rti **return from ic1 service** *****end ex 10-2
m68hc11 main timer and real-time interrupt motorola reference manual 10-49 listing - timer examples sheet 6 of 16 * timer example 10-3 measuring long periods with ic * * uses interrupts. * measures period between two rising edges at the ic1 pin. * overflows are counted so max is 16,777,215 cyc ( ? 8.38 sec) * min time measurable with this program is about 70 cyc * * this program runs on an evb board and displays results * on the evb terminal display. *** * initialization portion * c101 8e 00 47 [3] p24inz lds # $0047 top of users stack area on evb c104 86 7e [2] ldaa # $7e jump (extended) opcode c106 97 d0 [3] staa pvtof tof pseudo vector see manual c108 97 e8 [3] staa pvic1 ic1 pseudo vector c10a ce c1 71 [3] ldx #sv3tof address of tof service routine c10d df d1 [4] stx pvtof+1 finish jmp inst to tof routine c10f ce c1 7f [3] ldx #sv3ic1 address of ic1 service routine c112 df e9 [4] stx pvic1+1 finish jmp inst to ic1 routine * main program portion of per24 program * c114 ce 10 00 [3] per24t ldx #regbas point to register block c117 86 10 [2] ldaa #%00010000 top of main for per24 prog c119 a7 21 [4] staa tctl2,x edg1b:edg1a=0:l ic1 rising edge c11b 86 ff [2] ldaa # $ff c11d b7 d0 06 [4] staa ic1mod ff-ic1 off; 0-1st; 1-last edge c120 7f d0 05 [6] clr ic1dun signal period not done c123 1d 23 fb [7] bclr tflg1,x $fb clear ic1f (if any) c126 1d 25 7f [7] bclr tflg2,x $7f clear tof (if any) c129 1c 22 04 [7] bset tmsk1,x $04 enable ic1 interrupts c12c 1c 24 80 [7] bset tmsk2,x $80 enable tof interrupts c12f 0e [2] cli enable interrupts c130 b6 d0 05 [4] waitl3 ldaa ic1dun sets after period done c133 27 fb [3] beq waitl3 loop till period has been timed c135 0f [2] sei done, disable interrupts * display period as x.xxxxxx seconds (to nearest m s) c136 ce d0 07 [3] ldx #ovcnt1 point at hi byte of 6 digit hex c139 64 00 [6] lsr o,x 24-bit +2 to change to m s c13b 66 01 [6] ror 1,x (lcyc=0.5 m s) c13d 66 02 [6] ror 2,x rors include carry c13f 24 0a [3] bcc arnup3 ? need to round result ? c141 6c 02 [6] inc 2,x yes; round up c143 26 06 [3] bne arnup3 carry to middle byte ? c145 6c 01 [6] inc 1,x yes c147 26 02 [3] bne arnup3 carry to high byte ? c149 6c 00 [6] inc 0,x yes c14b bd c3 6c [6] arnup3 jsr h6tod8 convert to 8 digit decimal c14e bd ff c4 [6] jsr .outcrl begin printing result
motorola main timer and real-time interrupt m68hc11 10-50 reference manual listing - timer examples sheet 7 of 16 c151 ce d0 18 [3] ldx #dbufr+1 start at 2nd digit (1st is 0) c154 a6 00 [4] ldaa 0,x seconds digit c156 bd ff b8 [6] jsr .outa print c159 86 2e [2] ldaa #. ascii period c15b bd ff b8 [6] jsr .outa print c15e 08 [3] dumplp inx advance pointer to next digit c15f a6 00 [4] ldaa 0,x get digit c161 bd ff b8 [6] jsr .outa print it c164 8c d0 1e [4] cpx #dbufr+7 was that the last ? c167 26 f5 [3] bne dumplp if not continue c169 ce c4 04 [3] ldx #msgsec point at rest of display line c16c bd ff ca [6] jsr .outsto print seconds c16f 20 a3 [3] bra per24t goto top of main & repeat * * end of main program portion *** * sv3tof - timer overflow service routine * * called whenever any timer overflow is detected. if * the ic1 period measurement is in progress (ic1mod * positive) then the overflow counter (upper 8-bits of * period) is incremented. *** c171 7d d0 06 [6] sv3tof tst ic1mod if 0 or 1 ic1 active-count tofs c174 2b 03 [3] bmi ou3tof if neg, ic1 not active c176 7c d0 07 [6] inc ovcnt1 increment ic1 overflow count c179 86 80 [2] ou3tof ldaa # $80 c17b b7 10 25 [4] staa regbas+tflg2clear overflow flag c17e 3b [12] rti **return from tof service** *** * sv3ic1 - input capture 1 service routine * * called first when a rising edge is detected and again * when another rising edge is detected. *** c17f ce 10 00 [3] sv3ic1 ldx #regbas point at top of register block c182 7c d0 06 [6] inc ic1mod $ff->0 at 1st edge; 0->1 at 2nd c185 26 13 [3] bne no1st3 if not 0, this is second edge * process first edge of period c187 7f d0 07 [6] clr ovcnt1 zero the overflow count c18a ec 10 [5] ldd tic1,x read time of first edge c18c fd d0 08 [5] std res1 save till next capture c18f 2b 27 [3] bmi ou3ic1 done if ic was before any tof c191 a6 25 [4] ldaa tflg2,x check for tof in msb c193 2a 23 [3] bpl ou3ic1 if no overflow, youre done c195 7a d0 07 [6] dec ovcnt1 this tof shouldnt count * decrement ovcnt1 to -1.... * tof svc routine will inc back to zero c198 20 1e [3] bra ou3ic1 done processing first edge
m68hc11 main timer and real-time interrupt motorola reference manual 10-51 listing - timer examples sheet 8 of 16 * process second edge of period c19a ec 10 [5] no1st3 ldd tic1,x get time of second edge c19c 2b 07 [3] bmi arnov1 if msb=1, skip tof check c19e 6d 25 [6] tst tflg2,x check for overflow c1a0 2a 03 [3] bpl arnov1 if no tof, skip increment c1a2 7c d0 07 [6] inc ovcnt1 tof was before edge so count it c1a5 b3 d0 08 [6] arnov1 subd res1 time of last minus time of 1st c1a8 fd d0 08 [5] std res1 update result c1ab 24 03 [3] bcc res1ok check for borrow c1ad 7a d0 07 [6] dec ovcnt1 if borrow, fix overflow count c1b0 1d 21 30 [7] res1ok bclr tctl2,x $30 disable ic1 c1b3 86 01 [2] ldaa #1 c1b5 b7 d0 05 [4] staa ic1dun signal period measured c1b8 1d 23 fb [7] ou3ic1 bclr tflg1,x $fb clear ic1f c1bb 3b [12] rti **return from ic1 service** * *** end ex 10-3 * timer example 10-4 simple output compare example * * exl0-4 uses polled mode. * generate a 10ms period like you would use to time an ee write * but rather than wear out the eeprom just change an output pin * * example 10-4 runs on an evb board and drives pb0 high for * 10ms once every 30ms so you can see on an oscilloscope. *** c1bc ce 10 00 [3] inza ldx #regbas point to register block c1bf 86 80 [2] ldaa # $80 c1c1 a7 23 [4] staa tflg1,x clear any pending oc1f flag c1c3 6f 04 [6] clr portb,x initialize port b to zeros c1c5 86 01 [2] top4a ldaa #1 top of ex10-4a c1c7 a7 04 [4] staa portb,x set lsb of port b * this is where the 10ms delay part actually starts * c1c9 ec 0e [5] ldd tcnt,x get current timer count c1cb c3 4e 20 [4] addd #20000 what will count be in loms? c1ce ed 16 [5] std toc1,x set oc1 to trigger then c1d0 1f 23 80 fc[7] lp1 brclr tflg1,x $80 lp1 loop here till oclf=l * *delay is actually done here; rest is just support c1d4 1d 23 7f [7] bclr tflg1,x $7f clear oc1f c1d7 6f 04 [6] clr portb,x clear pb0 pin c1d9 18 ce 16 4e[4] ldy #5710 5710*(7 ? /loop)= about 2oms c1dd 18 09 [4] dlp1 dey top of software delay loop c1df 26 fc [3] bne dlp1 loop till y is zero c1e1 20 e2 [3] bra top4a repeat continuously for o-scope * *****end ex 10-4
motorola main timer and real-time interrupt m68hc11 10-52 reference manual listing - timer examples sheet 9 of 16 *** * timer example 10-5 square wave using output compare * * ex10-5 uses interrupts. * generate a square wave at the pa6 output pin using oc2 * * this program runs on an evb board. the half-cycle delay * time is entered into the double byte variable "hdly" at * $d000,d001 with a memory modify before going to the program. *** c1e3 8e 00 47 [3] top5 lds # $0047 top of users stack area on evb c1e6 86 7e [2] ldaa # $7e jump (extended) opcode c1e8 97 d0 [3] staa pvoc2 oc2 pseudo vector see manual c1ea ce c1 fd [3] ldx #sv5oc2 address of oc2 service routine c1ed df dd [4] stx pvoc2+1 finish jmp inst to tof routine c1ef ce 10 00 [3] ldx #regbas point to register block c1f2 86 40 [2] ldaa #%01000000 om2:ol2 = 0:1 c1f4 a7 20 [4] staa tctl1,x setup oc2 to toggle on compares c1f6 a7 23 [4] staa tflg1,x clear any pending oc2f c1f8 a7 22 [4] staa tmsk1,x enable oc2 interrupts c1fa 0e [2] cli enable interrupts c1fb 20 fe [3] bra * interrupt driven from here *** * sv5oc2 - output compare 2 service routine * * called at each oc2 interrupt. *** c1fd fc d0 00 [5] sv5oc2 ldd hdly get delay time for 1/2 cycle c200 e3 18 [6] addd toc2,x add to last compare value c202 ed 18 [5] std toc2,x update oc2 (schedule next edge) c204 1d 23 bf [7] bclr tflg1,x $bf clear oc2f c207 3b [12] rti **return from oc2 service** * *****end ex 10-5 * timer example 10-6 * oc1, oc2, and oc3 used together to produce 2 pwm signals * * oc1 controls two pins of port a in conjunction with oc2 and oc3 * oc1 drives the period and the scheduling of oc2 and oc3 * oc2 & oc3 automatically control pins but dont generate interrupts * set "pwmp1p", "pwmdc1" & "pwmdc2" manually before running this example * "pwmp1p" sets size of a 1% segment of pwm period (cycles) * min pwmp1p for this program is 2 (period = 200 cycles) * "pwmdc1" sets duty cycle for oc2 pin in % (0 to $64 hex) * "pwmdc2" sets duty cycle for oc3 pin in % (0 to $64 hex) * duty cycle (%) will be translated into a # of cycles offset * and period will be calculated as (100 * pwmp1p) at prog start * pa4 pin will toggle at each oc1 compare as a scope reference signal
m68hc11 main timer and real-time interrupt motorola reference manual 10-53 listing - timer examples sheet 10 of 16 * produces high going pwm signals of the period and duty cycle specified * note actually only produces pwms of 50% to 100% because specd duty of * 0 to 50% is changed to low going pwm w/duty cyc = [100% - spec(0-50)] * * this program runs on an evb board and drives output pins. * an oscilloscope is used to study the results. *** c208 8e 00 47 [3] inz6 lds # $0047 top of users stack area on evb c20b 86 7e [2] ldaa # $7e jump (extended) opcode c20d 97 df [3] staa pvoc1 oc1 pseudo vector see manual c20f ce c2 69 [3] ldx #sv6oc1 address of oc1 service routine c212 df e0 [4] stx pvoc1+1 finish jmp inst to oc1 routine c214 ce 10 00 [3] ldx #regbas point to register block c217 86 50 [2] ldaa #%01010000 omx:olx = 0:1 for toggle c219 a7 20 [4] staa tctl1,x oc2 and oc3 for toggle c21b 86 70 [2] ldaa #%01110000 oc1m6,5, & 4 = 1 c21d a7 0c [4] staa oc1m,x control oc2/pa6, oc3/pa5, & pa4 c21f 5f [2] clrb build oc1d initial value in b c220 b6 d0 03 [4] ldaa pwmdc1 check for oc2 duty > or = 50% c223 81 32 [2] cmpa #50 c225 23 02 [3] bls arnz61 if<50% oc1 goes lo oc2 togls hi c227 cb 40 [2] addb #%01000000 else oc1 goes high oc2 togls lo c229 b6 d0 04 [4] arnz61 ldaa pwmdc2 check for oc3 duty > or = 50% c22c 81 32 [2] cmpa #50 c22e 23 02 [3] bls arnz62 i<50% oc1 goes lo oc3 togls hi c230 cb 20 [2] addb #%00100000 else oc1 goes hi, oc3 togls lo c232 e7 0d [4] arnz62 stab oc1d,x store starting value for oc1d * calculate period & duty cycle as cycle count offsets c234 b6 d0 02 [4] ldaa pwmp1p 1% of period c237 c6 64 [2] ldab #100 c239 3d [10] mul 100 * pwmp1p = pwmper c23a fd d0 1f [5] std pwmper store period c23d ed 16 [5] std toc1,x start 1st pwm per @ tcnt=pwmper c23f b6 d0 03 [4] ldaa pwmdc1 calculate offset for oc2 c242 8d 12 [6] bsr caloff adj duty as reqd & calc offset c244 ed 18 [5] std toc2,x schedule first oc2 toggle c246 b6 d0 04 [4] ldaa pwmdc2 calculate offset for oc3 c249 8d 0b [6] bsr caloff adj duty as reqd & calc offset c24b ed 1a [5] std toc3,x schedule first oc3 toggle * finish initialization c24d 86 80 [2] ldaa # $80 c24f a7 23 [4] staa tflg1,x oc1f=1 to clr any old oc1 flag c251 a7 22 [4] staa tmsk1,x then oc1i=1 to enable oc1 int. c253 0e [2] cli c254 20 fe [3] bra * oc1 interrupt runs pwms now
motorola main timer and real-time interrupt m68hc11 10-54 reference manual listing - timer examples sheet 11 of 16 *** local subroutine to change duty cycle to offset cnt * if duty < 50% ($32) change to 100-duty * if duty >100% ($64) force to $64 * finally mult by 1% of period (cyc) * enter with pwmdcx duty in a-reg, return offset in d c256 81 32 [2] caloff cmpa #50 check for 0-49% c258 24 04 [3] bhs arn6a around fixup c25a 16 [2] tab if <50% set to 100 - duty cycle c25b 86 64 [2] ldaa #100 c25d 10 [2] sba a-b to a c25e 81 64 [2] arn6a cmpa #100 check for > 100% c260 23 02 [3] bls arn6b c262 86 64 [2] ldaa #100 if > 100% - set to 100% c264 f6 d0 02 [4] arn6b ldab pwmp1p c267 3d [10] mul pwmp1p * adjd duty cyc =offocx c268 39 [5] rts **return from caloff** * *** *** * sv6oc1 - output compare 1 service routine *** c269 ce 10 00 [3] sv6oc1 ldx #regbas point to register block c26c a6 0d [4] ldaa oc1d,x make pa4 flip @ nxt oc1 compare c26e 88 10 [2] eora #%00010000 flips oc1d4 bit(pa4 pin contrl) c270 a7 0d [4] staa oc1d,x update nxt oc1 auto pattern c272 ec 18 [5] ldd toc2,x get last oc2 compare value c274 f3 d0 1f [6] addd pwmper add count equiv to period c277 ed 18 [5] std toc2,x update oc2 (schedule next oc2) c279 ec 1a [5] ldd toc3,x get last oc3 compare value c27b f3 d0 1f [6] addd pwmper add count equiv to period c27e ed 1a [5] std toc3,x update oc3 (schedule next oc3) c280 ec 16 [5] ldd toc1,x get last oc1 compare value c282 f3 d0 1f [6] addd pwmper add count equiv to period c285 ed 16 [5] std toc1,x update oc1 (schedule next ocl) c287 1d 23 7f [7] bclr tflg1,x $7f clear oc1f c28a 3b [12] rti return from oc1 service * **** end ex 10-6 *** * timer example 10-7 * oc2 used alone to produce one pwh signal * * oc2 controls period and duty cycle of one port a pin * set pwmp1p & pwmdc1 manually before running this * example * pwmp1p sets size of a 1% segment of pwm period * (in cycles) * pwmdc1 sets duty cycle for oc2 pin in % - note: this * program will not work properly with values of duty * cycle too near 0 or 100% * refer to users manual text for discussions * program calculates offhi and offlo at start
m68hc11 main timer and real-time interrupt motorola reference manual 10-55 listing - timer examples sheet 12 of 16 * this program runs on evb board & drives pa6/oc2 pin. * an oscilloscope is used to study the results. *** c28b 8e 00 47 [3] inz7 lds # $0047 top of users stack area on evb c28e 86 7e [2] ldaa # $7e jump (extended) opcode c290 97 d0 [3] staa pvoc2 oc2 pseudo vector c292 ce c2 c2 [3] ldx #sv7oc2 address of oc2 service routine c295 df dd [4] stx pvoc2+1 finish jmp instruc to oc2 prog c297 ce 10 00 [3] ldx #regbas point to register block c29a b6 d0 03 [4] ldaa pwmdc1 calculate oc2 high time c29d f6 d0 02 [4] ldab pwmp1p 1% of period c2a0 3d [10] mul * pwmp1p * duty cycle = high part of period c2a1 fd d0 21 [5] std offhi save high offset c2a4 b6 d0 02 [4] ldaa pwmp1p 1% of period c2a7 c6 64 [2] ldab #100 c2a9 3d [10] mul 100 * pwmp1p = period c2aa b3 d0 21 [6] subd offhi period - high time = low time c2ad fd d0 23 [5] std offlo store low offset * finish initialization c2b0 86 c0 [2] ldaa #%11000000 om2:ol2 = 1:1 for set pin high c2b2 a7 20 [4] staa tctl1,x 1st oc2 starts first high time c2b4 cc 00 00 [3] ldd # $0000 c2b7 ed 18 [5] std toc2,x start 1st pwm period @ tcnt=0 c2b9 86 40 [2] ldaa # $40 c2bb a7 23 [4] staa tflg1,x oc2f=1 to clr any old oc2 flag c2bd a7 22 [4] staa tmsk1,x then oc2i=1 to enable oc2 inter c2bf 0e [2] cli c2c0 20 fe [3] bra * oc2 interrupt runs pwm now *** * sv7oc2 - output compare 2 service routine *** c2c2 ce 10 00 [3] sv7oc2 ldx #regbas point to register block c2c5 1f 20 40 05[7] brclr tctl1,x %01000000 addlo which half of cyc? c2c9 fc d0 21 [5] ldd offhi high part so add offhi to oc2 c2cc 20 03 [3] bra upoc2 c2ce fc d0 23 [5] addlo ldd offlo low part so add offlo to oc2 c2d1 e3 18 [6] upoc2 addd toc2,x add to last compare value c2d3 ed 18 [5] std toc2,x update oc2 (schedule next edge) c2d5 a6 20 [4] ldaa tctl1,x change ol2 to setup next edge c2d7 88 40 [2] eora #%01000000 inverts ol2 bit c2d9 a7 20 [4] staa tctl1,x update control reg c2db 1d 23 bf [7] bclr tflg1,x $bf clear oc2f c2de 3b [12] rti **return from oc2 service** * ***** end ex 10-7
motorola main timer and real-time interrupt m68hc11 10-56 reference manual listing - timer examples sheet 13 of 16 *** * general purpose subroutines *** *** * p5dec - subroutine to display a five digit decimal * number at "dbufr". * prints in the form xx,xxx with leading zeros * suppressed. prints 6 columns, leading spaces, * units always prints (0-9) * * calls evb routine ".outa" * calls "skp1" with bsr to advance x and print a * leading space skp1 subroutine follows p5dec * all registers are unchanged upon return from p5dec *** c2df 3c [4] psdec pshx save registers c2e0 37 [3] pshb c2e1 36 [3] psha c2e2 ce d0 17 [3] ldx #dbufr point at decimal (ms character) c2e5 86 30 [2] ldaa # $30 chk for leading 0s (ascii) c2e7 a1 00 [4] cmpa 0,x check 10,000s digit c2e9 26 19 [3] bne p10k start at 10k digit c2eb 8d 3d [6] bsr skp1 inx & print a space c2ed a1 00 [4] cmpa 0,x chk 1,000s (a still=ascii) c2ef 26 19 [3] bne p1k start at 1k digit c2f1 8d 37 [6] bsr skp1 inx & print a space c2f3 8d 35 [6] bsr skp1 inx & print extra sp for , c2f5 09 [3] dex just wanted so back up 1 c2f6 a1 00 [4] cmpa 0,x check 100s digit c2f8 26 1b [3] bne p100 start at 100s digit c2fa 8d 2e [6] bsr skp1 inx & print a space c2fc a1 00 [4] cmpa 0,x check 10s digit c2fe 26 1b [3] bne p10 start at 10s digit c300 8d 28 [6] bsr skp1 inx & print a space c302 20 1d [3] bra p1 start at 1s digit (default) c304 a6 00 [4] p10k ldaa 0,x 10,000s digit c306 bd ff b8 [6] jsr outa print 10,000s digit c309 08 [3] inx advance pointer to next digit c30a a6 00 [4] p1k ldaa 0,x 1,000s digit c30c bd ff b8 [6] jsr outa print it c30f 86 2c [2] ldaa #, ascii comma c311 bd ff b8 [6] jsr outa print c314 08 [3] inx advance pointer to next digit c315 a6 00 [4] p100 ldaa 0,x 100s digit c317 bd ff b8 [6] jsr .outa print it c31a 08 [3] inx advance pointer to next digit c31b a6 00 [4] p10 ldaa 0,x 10s digit c31d bd ff b8 [6] jsr outa print it c320 08 [3] inx advance pointer to next digit c321 a6 00 [4] p1 ldaa 0,x 1s digit c323 bd ff b8 [6] jsr outa print it c326 32 [4] pula restore registers c327 33 [4] pulb c328 38 [5] pulx c329 39 [5] rts **return from p5dec**
m68hc11 main timer and real-time interrupt motorola reference manual 10-57 listing - timer examples sheet 14 of 16 *** local skp1 subroutine (called from above with bsrs) c32a 36 [3] skpi psha save a c32b 08 [3] inx advance x c32c 86 20 [2] ldaa # $20 ascii c32e bd ff b8 [6] jsr outa print the c331 32 [4] pula restore a c332 39 [5] rts ** return from skp1 ** *** * htod - subroutine to convert a 16-bit hex number to a * 5 digit decimal number. * * uses 5 byte variable dbufr for decimal ascii result * on entry x points to hex value to be converted & * displayed * all registers are unchanged upon return *** c333 3c [4] htod pshx save registers c334 37 [3] pshb c335 36 [3] psha c336 ec 00 [5] ldd 0,x d=hex value to be converted c338 ce 27 10 [3] ldx #10000 c33b 02 [41] idiv freq+10,000 -> x; r -> d c33c 8f [3] xgdx sav r in x 10,000s digit in a:b c33d cb 30 [2] addb # $30 convert to ascii c33f f7 d0 17 [4] stab dbufr store in decimal buffer c342 8f [3] xgdx r back to d c343 ce 03 e8 [3] ldx #1000 c346 02 [41] idiv r+1,000 -> x; r -> d c347 8f [3] xgdx sav r in x; 1,000s digit in a:b c348 cb 30 [2] addb # $30 convert to ascii c34a f7 d0 18 [4] stab dbufr+1 store in decimal buffer c34d 8f [3] xgdx r back to d c34e ce 00 64 [3] ldx #100 c351 02 [41] idiv r+100 -> x; r -> d c352 8f [3] xgdx save r in x; 100s digit in a:b c353 cb 30 [2] addb # $30 convert to ascii c355 f7 d0 19 [4] stab dbufr+2 store in decimal buffer c358 8f [3] xgdx r back to d c359 ce 00 0a [3] ldx #10 c35c 02 [41] idiv r+10 -> x; r in d (b= 1s digit) c35d cb 30 [2] addb # $30 convert to ascii c35f f7 d0 1b [4] stab dbufr+4 store to units digit c362 8f [3] xgdx 10s digit to d (a:b) c363 cb 30 [2] addb # $30 convert to ascii c365 f7 d0 1a [4] stab dbufr+3 store in decimal buffer c368 32 [4] pula restore registers c369 33 [4] pulb c36a 38 [5] pulx c36b 39 [5] rts **return**
motorola main timer and real-time interrupt m68hc11 10-58 reference manual listing - timer examples sheet 15 of 16 *** * h6tod8 - subroutine to convert a 24-bit hex number to * an 8 digit decimal number. * * uses 3 byte variable "htemp" for hex working value * uses 8 byte variable "dbufr" for decimal ascii result * on entry x points to the hex value to be converted & * displayed * all registers are unchanged upon return *** c36c 18 3c [5] h6tod8 pshy save registers c36e 3c [4] pshx c36f 37 [3] pshb c370 36 [3] psha c371 ec 01 [5] ldd 1,x move hex to htemp to convert c373 fd d0 0b [5] std htemp+1 two lower bytes moved c376 a6 00 [4] ldaa 0,x upper byte c378 b7 d0 0a [4] staa htemp c37b 18 ce d0 17[4] ldy #dbufr pnt @ ms digit of decimal bufr c37f ce c4 0d [3] ldx #con10m point at first 24-bit constant c382 4f [2] htdlp clra a keeps track of # of subtracts c383 4c [2] hlpin inca inner loop; once per subtract c384 f6 d0 0c [4] ldab htemp+2 start 24-bit subtract c387 e0 02 [4] subb 2,x c389 f7 d0 0c [4] stab htemp+2 update low byte c38c f6 d0 0b [4] ldab htemp+1 middle byte c38f e2 01 [4] sbcb 1,x sub with carry c391 f7 d0 0b [4] stab htemp+1 update middle byte c394 f6 d0 0a [4] ldab htemp high byte c397 e2 00 [4] sbcb 0,x c399 f7 d0 0a [4] stab htemp update high byte c39c 24 e5 [3] bcc hlpin if no borrow; subtract again c39e f6 d0 0c [4] ldab htemp+2 last subtract too far; add back c3a1 eb 02 [4] addb 2,x c3a3 f7 d0 0c [4] stab htemp+2 update low byte c3a6 f6 d0 0b [4] ldab htemp+1 middle byte c3a9 e9 01 [4] adcb 1,x sub with carry c3ab f7 d0 0b [4] stab htemp+1 update middle byte c3ae f6 d0 0a [4] ldab htemp high byte c3b1 e9 00 [4] adcb 0,x c3b3 f7 d0 0a [4] stab htemp update high byte c3b6 8b 2f [2] adda # $2f convert digit to ascii c3b8 18 a7 00 [5] staa 0,y store to decimal buffer c3bb 18 08 [4] iny point to next decimal digit c3bd 08 [3] inx point to next 24-bit const c3be 08 [3] inx c3bf 08 [3] inx c3c0 8c c4 22 [4] cpx #conend see if done yet c3c3 26 bd [3] bne htdlp if not done, do nxt digit
m68hc11 main timer and real-time interrupt motorola reference manual 10-59 listing - timer examples sheet 16 of 16 c3c5 b6 d0 0c [4] ldaa htemp+2 get 1s digit c3c8 8b 30 [2] adda # $30 convert to ascii c3ca 18 a7 00 [5] staa 0,y store to last decimal digit c3cd 32 [4] pula restore registers c3ce 33 [4] pulb c3cf 38 [5] pulx c3d0 18 38 [6] puly c3d2 39 [5] rts return from h6tod8 * * display messages & constants * c3d3 20 43 79 63 6c msgcyc fcc cycles 65 73 20 20 20 20 20 c3df 04 fcb $04 end-of-message mark c3e0 20 48 7a msghz fcc hz c3e3 04 fcb $04 end-of-message mark c3e4 46 72 65 71 2e msger1 fcc freq. is too high 20 69 73 20 74 6f 6f 20 68 69 67 68 c3f5 04 fcb $04 end-of-message mark c3f6 20 6d 69 63 72 msgms fcc microseconds 6f 73 65 63 6f 6e 64 73 c403 04 fcb $04 end-of-message mark c404 20 53 65 63 6f msgsec fcc seconds 6e 64 73 c40c 04 fcb $04 end-of-message mark c40d 98 96 80 con10m fcb $98,$96,$80 = 24-bit equiv of 10,000,000 c410 0f 42 40 fcb $0f,$42,$40 = 24-bit equiv of 1,000,000 c413 01 86 a0 fcb $01,$86,$a0 = 24-bit equiv of 100,000 c416 00 27 10 fcb $00,$27,$10 = 24-bit equiv of 10,000 c419 00 03 e8 fcb $00,$03,$e8 = 24-bit equiv of 1,000 c41c 00 00 64 fcb $00,$00,$64 = 24-bit equiv of 100 c41f 00 00 0a fcb $00,$00,$0a = 24-bit equiv of 10 c422 conend equ *dont need 1s const *end of file *0 error(s)
motorola main timer and real-time interrupt m68hc11 10-60 reference manual
m68hc11 pulse accumulator motorola reference manual 11-1 section 11 pulse accumulator the pulse accumulator, which is similar to the timers in older mc6805 mcus, is a much simpler system than the main timer discussed in section 10 main timer and real-time interrupt . this system is based on an 8-bit counter and can be configured to operate as a simple event counter or for gated time accumulation. unlike the main timer, the 8-bit pulse accumulator counter can be read or written at any time (the 16-bit counter in the main timer cannot be written). control bits allow the user to configure and control the pulse accumulator subsystem. two maskable interrupts are associated with the system, each having its own controls and interrupt vector. the port a bit 7 i/o pin (pa7/pai/oc1) associated with the pulse accumulator can be configured to act as a clock (event counting mode) or as a gate signal to enable a free- running e divided by 64 clock to the 8-bit counter (gated time accumulation mode). the alternate functions of the pulse accumulator input (pai) pin present some interesting application possibilities. 11.1 general description the pulse accumulator is an 8-bit counter/timer system that can be configured to op- erate in either of two basic modes. in the event counting mode, the 8-bit counter is clocked to increasing values at each active edge of the pai pin. in the gated time ac- cumulation mode, the 8-bit counter is clocked by a free-running e divided by 64 clock subject to the pai pin being active. figure 11-1 is a simplified block diagram of the pulse accumulator in each of these two possible modes. figure 11-1 pulse accumulator operating modes table 11-1 summarizes the important timing periods for the pulse accumulator (when operating in gated time accumulation mode) for various common crystal rates. the for- mulas at the bottom of the table can be used for a different crystal frequency than those shown. pa7/ pai/ oc1 pin 8-bit counter pacnt clock pa7/ pai/ oc1 pin 8-bit counter pacnt clock e ? 64 clock (from main timer) pamod = 1 gated-time accumulation mode pamod = 0 event counting mode
motorola pulse accumulator m68hc11 11-2 reference manual the free-running e divided by 64 clock is a tap off the main timer clocking chain (see 10.2.1 overall clock divider structure and figure 10-3 ). in general, any signal ap- plied to the pai pin is asynchronous to this e divided by 64 clock; therefore, the first count could occur anywhere between zero and 64 e clocks after the pai pin goes to the chosen active level. user software can enable the pulse accumulator system, select its mode, and deter- mine the polarity of signals recognized at the pai pin. two separate interrupts are as- sociated with the pulse accumulator system: one is generated by detection of a selected edge at the pai pin; the other is generated when the 8-bit counter rolls over from $ff to $00 (overflow). each of these interrupt sources has its own local enable bit and its own interrupt vector; thus, no software polling is required to determine the cause of any pulse accumulator interrupts. 11.1.1 pulse accumulator block diagram figure 11-2 is a functional block diagram of the pulse accumulator subsystem. the central element of this system is an 8-bit up-counter that can be read or written at any time. the pulse accumulator enable (paen) control bit enables/disables this 8-bit counter. the pulse accumulator mode (pamod) bit selects the clock source to this counter. in the event counting mode, the clock is the output of the edge detector of the pai pin. in the gated time accumulation mode, the clock is a free-running, internal e divided by 64 clock anded (gated) with the active level of the pai pin. the pulse ac- cumulator edge select (pedge) bit controls the polarity of signals on the pai pin that will be recognized by the pulse accumulator system. the pulse accumulator overflow interrupt enable (paovi) bit determines whether or not a pulse accumulator overflow interrupt flag (paovf) will generate hardware interrupt requests. the pulse accumu- lator input edge interrupt enable (paii) bit determines whether or not detected edges at the pai pin will cause the pulse accumulator input flag (paif) to be set (generating hardware interrupt requests). in addition to the paii and paovi local interrupt enables, these interrupts are subject to masking by the i bit in the condition code register in the central processing unit (cpu). for additional information about interrupts, refer to section 5 resets and interrupts . the input buffer on the pai pin is always connected from the pin to the pulse accumu- lator and port a read logic, but the output buffer is enabled or disabled by the data di- rection control bit (ddra7) in the pulse accumulator control (pactl) register. normally, when the pulse accumulator is being used, the pai pin is configured as a high-impedance input (ddra7 = 0), but it is possible for software or the main timer (by way of output compare 1) to directly control the pulse accumulator by setting ddra7 equal to one (output). a detailed transistor-level schematic of this pin logic is shown in table 11-1 pulse accumulator timing periods vs. crystal rate 2.1 mhz 2 23 hz 477 ns 30.52 m s 7.81 ms 2 mhz 8 mhz 500 ns 32 m s 8.19 ms 1 mhz 4 mhz 1 m s64 m s 16.38 ms formula: 64(e period) 16,384(e period)
m68hc11 pulse accumulator motorola reference manual 11-3 section 7 parallel input/output . figure 11-2 block diagram of pulse accumulator subsystem 11.1.2 pulse accumulator control and status registers figure 11-3 shows all control and status registers related to the pulse accumulator. each of these registers and bits is discussed in detail in the following paragraphs. the 8-bit pulse accumulator counter (pacntC$1027) is not affected by reset and can be read or written any time. counting is synchronized to the internal ph2 clock so that incrementing and reading occur during opposite half cycles. pacnt 8-bit counter 2:1 mux pa7/ enable overflow 1 2 interrupt requests internal data bus input buffer & edge detection pactl tflg2 tmsk2 paovi paii ddra7 paen pamod pedge paovf paif 11 pulse acc block output buffer pai edge paen e ? 64 clock (from main timer) pai/oc1 from main timer oc1 disable flag setting
motorola pulse accumulator m68hc11 11-4 reference manual figure 11-3 pulse accumulator control and status register summary the following register and paragraphs describe the pulse accumulator related bits in the pactl register. bits 2 and 3 are not implemented and always read as zeros. al- though bits 0 and 1 are not related to the pulse accumulator, an awareness of these real-time interrupt rate bits is necessary to prevent inadvertent change while writing to the pulse accumulator related bits. ddra7 data direction control for port a bit 7 0 = port a bit 7 is configured for input only (output buffer is disabled). 1 = port a bit 7 is configured for output. normally when the pulse accumulator is being used, the pai pin will be configured as an input. in unusual cases, the pa7/pai/oc1 pin can be configured as an output to allow oc1 or a software output to drive the pulse accumulator system. since the input buffer is always connected to the pin (even when the pin is configured as an output), any output function that is controlling the pa7 pin will also be driving the pulse accu- mulator. paen pulse accumulator enable 0 = pulse accumulator disabled. tmsk2 timer interrupt mask 2 register $1024 bit 7 654321 bit 0 toi rtii paovi paii 0 0 pr1 pr0 reset: 00000000 tflg2 timer interrupt flag 2 register $1025 bit 7 654321 bit 0 tof rtif paovf paif 0000 reset: 00000000 pactl pulse accumulator control register $1026 bit 7 654321 bit 0 ddra7 paen pamod pedge 0 0 rtr1 rtr0 reset: 00000000 pacnt pulse accumulator count register $1027 bit 7 654321 bit 0 bit 7 bit 0 reset: pactl pulse accumulator control register $1026 bit 7 654321 bit 0 ddra7 paen pamod pedge 0 0 rtr1 rtr0 reset: 00000000
m68hc11 pulse accumulator motorola reference manual 11-5 1 = pulse accumulator enabled. when the pulse accumulator is disabled, the 8-bit counter stops counting, and pulse accumulator interrupts are inhibited. though the flags cannot become set, they will re- main set if they were ones at the time the pulse accumulator was disabled. pamod pulse accumulator mode select 0 = external event counting mode (pin acts as clock). 1 = gated time accumulation mode (pin acts as clock enable for e divided by 64 clock). pedge pulse accumulator edge select 0 = pulse accumulator responds to falling edges (inhibit gate level is zero). 1 = pulse accumulator responds to rising edges (inhibit gate level is one). in gated time accumulation mode (pamod = 1), the pedge bit has added meaning. in addition to specifying the edge polarity that causes the paif bit to be set, pedge also controls the inhibit gate level, which disables the internal, free-running e divided by 64 clock to the pulse accumulator counter. the paif interrupts occur at the trailing edge of a gate enable signal; thus, selecting falling edges causes the free-running e divided by 64 clock to be disabled while the pai pin is low. the following registers and paragraphs explain the pulse accumulator interrupt flags and the pulse accumulator interrupt enable bits. the other bits in these registers not related to the pulse accumulator system are discussed in section 10 main timer and real-time interrupt . paovi, paovf pulse accumulator overflow interrupt enable and flag the paovf status bit is automatically set to one each time the pulse accumulator count rolls over from $ff to $00. this status bit is cleared by writing to the tflg2 reg- ister with a one in the corresponding data bit position (bit 4). the paovi control bit al- lows the user to configure the pulse accumulator overflow for polled or interrupt-driven operation but does not affect the setting or clearing of paovf. when paovi is zero, pulse accumulator overflow interrupts are inhibited, and the system is operating in a polled mode. in this mode, paovf must be polled (sampled) by user software to de- termine when an overflow has occurred. when the paovi control bit is one, a hard- ware interrupt request is generated each time paovf is set to one. before leaving the interrupt service routine, software must clear paovf by writing to the tflg2 register. for additional information, refer to 10.2.4 tips for clearing timer flags . tmsk2 timer interrupt mask 2 register $1024 bit 7 654321 bit 0 toi rtii paovi paii 0 0 pr1 pr0 reset: 00000000 tflg2 timer interrupt flag 2 register $1025 bit 7 654321 bit 0 tof rtif paovf paif 0000 reset: 00000000
motorola pulse accumulator m68hc11 11-6 reference manual paii, paif pulse accumulator input edge interrupt enable and flag the paif status bit is automatically set to one each time a selected edge is detected at the pa7/pai/oc1 pin. this status bit is cleared by writing to the tflg2 register with a one in the corresponding data bit position (bit 5). the paii control bit allows the user to configure the pulse accumulator input edge detect for polled or interrupt-driven op- eration but does not affect the setting or clearing of the paif bit. when paii is zero, pulse accumulator input interrupts are inhibited, and the system is operating in a polled mode. in this mode, the paif bit must be polled (sampled) by user software to deter- mine when an edge has occurred. when the paii control bit is one, a hardware inter- rupt request is generated each time paif is set to one. before leaving the interrupt service routine, software must clear paif by writing to the tflg2 register. for addi- tional information, refer to 10.2.4 tips for clearing timer flags . 11.2 event counting mode many microcontroller unit (mcu) applications require "things" to be counted. these things are called events, but in real applications they might be anything: pieces on an assembly line, cycles of an incoming signal, or units of time. to be counted by the pulse accumulator, these things must be translated into rising or falling edges on the pai pin. either edge will do because software can pick which edge will be recognized. a trivial example of event counting might be to count pieces on an assembly line. a light emitter/detector pair could be placed across the path of the pieces so that, as each piece passes the sensor, the light beam is interrupted and a logic-level signal is produced, which can be connected to the pai pin. 11.2.1 interrupting after n events by writing to the pacnt, the pulse accumulator can be set up to produce an interrupt after n events. the trick is to write the twos complement of the number (n) to pacnt so that the counter will overflow after n counts. if the following program sequence is used, the pacnt will overflow after the 100th count: ---- 86 64 [2] ldaa #100 hex ($64) ---- 40 [2] nega twos complement ($9c) ---- b7 10 27 [4] staa pacnt store to pulse accum counter 11.2.2 counting more than 256 events more than 256 events can be counted by using software to keep track of how many times the pacnt overflows. before the first event, calculate the number of overflows needed and a value corresponding to any remainder that is left after seeing how many whole times 256 goes into the intended count. two cases are used as examples. in the first case, 512 ($0200) events will be counted; in the second case, 515 ($0203) events will be counted. in both cases, assume the desired count is in the d register. since d is the concatenation of the a register (upper 8 bits of d) and the b register (lower 8 bits of d), division to see how many whole times 256 can go into the desired count is not necessary (the a register has this count). for case 1, two overflows are needed (there is no remainder). zero is stored to pacnt. for reasons illustrated in the following paragraphs, the user may wish to ne-
m68hc11 pulse accumulator motorola reference manual 11-7 gate the b register instead and store the result to pacnt (negative of $00 is $00). save a in a ram variable so software can decrement it at each overflow. as the pulse accumulator starts counting, the first overflow will occur after detecting the 256th event (counter counts $00-01-02 ... fe-ff-00). the second overflow will occur after the 512th count. if the ram variable was decremented at each overflow (it started at $02), it would become $00 after the second overflow (i.e., after the desired 512 events). for case 2, negate the b register and store the result to pacnt (negative of $03 is $fd). as the pulse accumulator starts counting, the first overflow will occur after de- tecting the third event (counter counts $fd-fe-ff-00). the second overflow will occur after the 259th count, and the third overflow will occur after the 515th count. a third overflow is needed because there was an initial remainder that had to be counted be- fore starting to count whole sets of 256 events. the user can write a program that will handle either case by checking the b register to see if it was zero. if it was not zero, the a register is incremented before storing it to the ram variable that keeps track of overflows. before negating the b register, test b and branch around an increment a register instruction if the b register was zero. this procedure is demonstrated in the following partial listing: ---- cc 02 03 [3] ldd #515 get desired count in a:b ---- 40 [2] tstb test for remainder count ---- 27 01 [2] beq arninc if none; skip the inca ---- 4c [2] inca increment the overflow count ---- 5o [2] arninc negb twos complement remainder in b ---- f7 10 27 [4] stab pacnt store to pulse accum counter ---- b7 d0 00 [4] staa ovcnt store to ram overflow variable the test b instruction can be eliminated (saving a byte of program space and two cy- cles of execution time) by checking the carry flag that results after the negate-b oper- ation. carry is set in all cases except when b is zero). the following partial listing demonstrates this slightly shorter procedure: ---- cc 02 03 [3] ldd #515 get desired count in a:b ---- 50 [2] negb c-bit only cleared if b was 0 ---- 27 01 [2] bcc arninc if b was ($00); skip the inca ---- 4c [2] inca increment the overflow count ---- f7 10 27 [4] arninc stab pacnt store twos comp. remainder count ---- b7 d0 00 [4] staa ovcnt store to ram overflow variable this alternate approach illustrates that a sophisticated, careful user can sometimes find tricks to save memory and execution time, but are they that important in all mcu applications? the costs of this trick and others like it are 1) it often makes the program slightly more difficult to understand (more risk of a mistake), and 2) it takes extra de- velopment time. remember, the savings in this case is just one byte of program space and two cycles of execution time. 11.3 gated time accumulation mode this mode changes the pulse accumulator from a counter into a timer. in this mode, the 8-bit pacnt is incremented every 64th e-clock cycle provided the pai pin is ac- tive. the pedge bit controls which level at the pai pin inhibits counting. this mode is
motorola pulse accumulator m68hc11 11-8 reference manual called gated time accumulation mode because the pacnt can be used to accumulate the total time the pin was active over a series of pulses. each time the pai pin goes to the chosen active level, the pacnt continues to count from where it left off at the end of the previous pulse. a more common use of gated time accumulation mode is to measure the duration of single pulses (pulse-width measurement). since this counter does not start counting until the input signal becomes active, pulse-width measurement is done a little differ- ently than it would be with a main timer input capture. with the pulse accumulator, the counter is set to zero before the pulse starts, and the resulting pulse time is directly read when the pulse is finished; whereas, with input capture, it is necessary to capture a starting count and an ending count and subtract. separate maskable interrupts are generated at counter overflow and at the trailing edge of the counter enable signal on the pai pin. the overflow interrupt is useful for generating interrupts after a specific time delay from when the pin became active or for measuring signals longer than the range of the 8-bit counter. the pai pin-related interrupt is useful for signaling the end of a timing period; software can then be used to see how long the input was active. these two interrupts can be used together to create a pulse-width discriminator for example, write the counter to a value that would cause an overflow interrupt half way between the time of the shorter pulse width and the longer pulse width. if the overflow triggers before the pai pin interrupt, the pulse is the longer size. if the pin interrupt triggers before the overflow interrupt, the pulse is the shorter size. if the pulse widths are longer than the range of the 8-bit counter, incorporate a software overflow counter into the overflow service routine and use the timeout of this software count, instead of the first paovf interrupt, to discrim- inate between pulse durations. 11.3.1 measuring times longer than the range of the 8-bit counter extending the timing range is done in much the same way as it is for input captures. because the pulse accumulator is 8-bits rather than 16-bits, overflows happen more often. as long as the input signal is active, the user would count overflows. the pai pin interrupt indicates when the pulse ends (by setting the paif status bit and option- ally generating an interrupt). the period of the pulse will be (256 n + pacnt) x (64 e periods/count) where: n equals the number of overflows pacnt equals the final count in the 8-bit pulse accumulator counter the problems associated with overflows, which occur near input capture edges in the main timer, are not present in the pulse accumulator. since the pacnt is not running before the leading edge of the pulse, there is no potential confusion about an overflow near this edge. at the trailing edge of the pulse, the pacnt also stops so any pending overflow will count in the total. the paovf interrupt is higher priority than the paif interrupt; therefore, a just-in-time overflow will always be serviced before servicing the
m68hc11 pulse accumulator motorola reference manual 11-9 trailing edge of a pulse so the paif service routine does not have to check for an over- flow. 11.3.2 configuring for interrupt after a specified time this concept is the time equivalent of setting up an interrupt after n events, which was previously discussed. first, calculate the number of e divided by 64 counts, which would be equivalent to the time period the user wants to specify. for example, if a de- lay of 5 ms is desired, divide 5 ms by the time for one e divided by 64 count (from ta- ble 11-1 , one count equals 32 m s for e = 2 mhz). since 5 ms divided by 32 m s equals 156.25, truncate to 156. the resolution of the counter causes a tolerance of 32 m s (64 e periods ;e=2 mhz). next, take the twos complement of this value and store the result in the pacnt. when the input goes to its chosen active level, the counter will start incrementing every 64 e cycles. an overflow will occur after the 156th count. 11.4 other uses for the pai pin at any time, software can read the logic level on the pa7/pai/oc1 pin even if one or more of the other functions associated with this pin is also enabled. this pin can also be used as an extra edge-triggered interrupt input pin when the pulse accumulator functions are not needed. (in fact, examples have been presented in this chapter where this pin is being used as an edge-triggered interrupt even while the pulse accu- mulator is being used.) this pin has some advantages over the irq pin. the pedge control bit allows the user to select either rising or falling edges ( irq cannot be con- figured to detect rising edges). the paii control bit allows the user to locally enable or disable this interrupt; in addition, the i bit in the cpu condition code register acts as a global enable for all i-bit-related interrupts. finally, the paif status flag allows software to detect a pending pai pin interrupt and to clear the pending interrupt if necessary (with irq this function is not possible). 11.5 timing details for the pulse accumulator the timing information presented in the following paragraphs is much more detailed than most users will ever need. this information is not intended to replace guaranteed datasheet timing information. figure 11-4 shows the timing related to edge detection at the pa7/pai/oc1 pin. pri- marily, this timing concerns the event counting mode, but the setting of the paif status flag applies to gated time accumulation mode as well. pai signals are synchronized to the internal phase 2 (ph2) clock to prevent any interference between clocking and reading the pacnt. this synchronization process limits the maximum counting rate for the pulse accumulator to one-half the e-clock frequency. any incoming edge [1] presented after the rising edge of e but before the next rising edge of e is recognized during ph2 high and causes the paif status flag [2] to be set at the falling edge of that ph2. in event counting mode, the pacnt counter is incre- mented at that same ph2 falling edge. the soonest another edge can be detected is two cycles later [3].
motorola pulse accumulator m68hc11 11-10 reference manual figure 11-4 pai pin edge-detection timing figure 11-5 pin enable vs. counting (gated accumulation mode) in gated time accumulation mode, an internal, free-running e divided by 64 clock drives the pacnt whenever the pai pin is at its chosen active level. figure 11-5 shows the timing relationship between the counter enable signal at the pai pin [1] and the start of counting. in general, the signal at the pai pin is asynchronous to the free- running e divided by 64 clock; thus, there would be an uncertainty about the delay be- tween the active level at the pai pin and the first increment of the pacnt. the first increment could come as early as [2], as late as [5], or at any ph2 falling edge between ([3], [4], etc.). knowing the relationship between software and the free-running e divided by 64 clock is not normally useful, but it is theoretically possible to determine this relationship. from figure 10-3 and the prescale control bit values (pr[1:0]), it can be determined where the e divided by 64 clock is tapped off the main timer. software can then read the low-order half of the 16-bit main timer counter to see when the next edge will ap- pear at the tap point. because this procedure can be involved, it is not worth pursuing unless there is a very good reason. ph2 paif e pacnt count n+1 n pai pin [1] [2] [3] ph2 e pacnt count pai pin [1] [2] [3] [4] [5] 63 cycles
m68hc11 pulse accumulator motorola reference manual 11-11 figure 11-6 shows timing details for a pulse accumulator counter overflow. at the ph2 falling edge where the pacnt count changes from $ff to $00 [1], the paovf bit also is set [2]. figure 11-6 timing details for pulse accumulator counter overflow reading or writing to the pacnt occurs in a portion of the ph2 cycle that eliminates conflicts between accesses to pacnt and counting. (a) shows the detailed timing for a read of pacnt; (b) shows a write. the address and data buses shown in are the internal buses that have different timing than the external buses. ph2 e pacnt count paovf [1] [2] $00 $ff
motorola pulse accumulator m68hc11 11-12 reference manual (a) pacnt read (b) pacnt write figure 11-7 pacnt read and write ph2 address bus (internal) e pacnt count ldaa pacnt read pulse accumulator count (extended) nn opcode addr operand (lo) operand (hi) next opcode data bus (internal) nn $0e $10 opcode $1027 pacnt fetch opcode fetch 16-bit operand address read pacnt ph2 address bus (internal) e pacnt count staa pacnt write to pulse accumulator (extended) nn opcode addr operand (lo) operand (hi) next opcode data bus (internal) nn $27 $10 opcode $1027 pacnt fetch opcode fetch 16-bit operand address write pacnt old count
m68hc11 analog-to-digital converter system motorola reference manual 12-1 section 12 analog-to-digital converter system the MC68HC11a8 analog-to-digital (a/d) converter system uses an all-capacitive charge-redistribution technique for conversions. the a/d system is an 8-channel, 8- bit, successive approximation converter with 1/2 least significant bit (lsb) accuracy over the complete operating temperature range. because of the charge-redistribution technique, no external sample and hold circuits are required. this section first discusses the charge-redistribution technique, which is useful in un- derstanding subtle details concerning the application of the MC68HC11a8 a/d sys- tem. the second part of this section includes a detailed description of the MC68HC11a8 a/d system and features. the section concludes with a discussion of how external circuitry can influence a/d accuracy. 12.1 charge-redistribution a/d figure 12-1 shows a simplified circuit to perform a 4-bit, successive-approximation a/ d conversion using charge redistribution. the actual circuit used in the MC68HC11a8 includes several additions to this simple circuit to improve quality and simplify manu- facturing. after an initial introduction to the charge-redistribution technique, some of these additions are discussed. since the capacitive charge redistribution technique depends upon capacitance ratios rather than absolute capacitance values, the capac- itors in figure 12-1 are marked in units. during the sample time ( figure 12-1 (a)), the top plate of all capacitors is switched to v l (0.0 v), and the bottom plates are connected to the unknown analog input, v x . us- ing the simple relationship q s equals cv, the total charge may be calculated by q s = 16(v x C v l ) unless otherwise stated, it is assumed v l equals 0.0 v; therefore, q s = 16 v x next, the circuit is changed to the hold state by logically controlled analog switches ( figure 12-1 (b)). in this state, the top plates are disconnected from v l , and the bottom plates are switched from v x to v l . the charge is now written as q h = (v l C v i ) 16 since v l = 0 q h = C 16 v i
motorola analog-to-digital converter system m68hc11 12-2 reference manual (a) sample mode (b) hold mode (c) approximation mode figure 12-1 basic charge-redistribution a/d since charge is conserved, q s equals q h ; therefore, v x + C v i 1 2 4 8 1 v l v l + C v l v i 1 2 4 8 1 v l + C v h v l v i msb 1 1 0 lsb successive-approximation register (sar) 1 0 1 0 1 0 2 4 8 1 v l v l
m68hc11 analog-to-digital converter system motorola reference manual 12-3 16 v x = C16 v i v x = Cv i v i = Cv x which is the initial voltage at the input of the comparator. finally, in the conversion portion of the a/d process, each capacitor, beginning with the largest one, which corresponds to the most significant bit (msb) of the digital re- sult, is switched from v l (0.0 v) to v h . the output of the comparator, after each ca- pacitor is switched, determines whether the bottom plate of that capacitor will remain at v h or be returned to v l before the next capacitor is switched. to understand how the process works, a conversion sequence is presented for an an- alog input, (v x equals 21/32 (v h ). during the sample time, the capacitors attain a total charge q s = 16 v x = (16) 21/32 (v h ) = 21/2 v h during hold, the minus input to the comparator (v i ) goes to Cv x or C21/32 v h . next, the eight-unit capacitor is switched from v l to v h resulting in the following circuit: the charge is written as follows: q = 8 (v h C v i ) + 8 (v l C v i ) but v l = 0; thus, q = 8 v h C 8 v i C 8 v i q = 8 v h C 16 v i by charge conservation, this charge is set equal to the original charge obtained during v h + C v l 1 2 4 8 1 v l v i
motorola analog-to-digital converter system m68hc11 12-4 reference manual the sample time: 21/2 v h = 8 v h C 16 v i solving for v i yields the following results: 16 v i = 8 v h C 21/2 v h v i = 1/2 v h C 21/32 v h v i = C 5/32 v h which is negative. since the output of the comparator is a logic one, the eight-unit capacitor remains con- nected to v h for the next step. also, bit 3 of the successive-approximation register (sar) is set to a logic one. after the conversion sequence, the sar contains the digital equivalent of the original analog input. next, the four-unit capacitor will be switched from v l to v h resulting in the following circuit: the charge is written as follows: q = 8(v h C v i ) + 4(v h C v i ) C 4 v i q = 8 v h C 8 v i + 4 v h C 4 v i C 4 v i q = 12 v h C 16 v i by charge conservation, this charge is set equal to the original charge: 21/2 v h = 12 v h C 16 v i solving for v i yields the following results: v h + C v l 1 2 4 8 1 v l v i
m68hc11 analog-to-digital converter system motorola reference manual 12-5 16 v i = 12 v h C 21/2 v h 16 v i = 3/2 v h v i = 3/32 v h which is positive. the output of the comparator is a logic zero; therefore, the four-unit capacitor returns to v l before proceeding to the next step. also, bit 2 of the sar is cleared to zero. next, the two-unit capacitor will be switched from v l to v h resulting in the following circuit: the charge is written as follows: q = 8(v h C v i ) + 2(v h C v i ) C 6 v i q = 8 v h C 8 v i + 2 v h C 2 v i C 6 v i q = 10 v h C 16 v i setting this charge equal to the original charge by charge conversion yields the follow- ing results: 21/2 v h = 10 v h C 16 v i 16 v i = 10 v h C 21/2 v h 16 v i = C 1/2 v h v i = C 1/32 v h which is negative. since the output of the comparator is now a logic one, the two-unit capacitor remains v h + C v l 1 2 4 8 1 v l v i
motorola analog-to-digital converter system m68hc11 12-6 reference manual connected to v h for the next step, and bit 1 of the sar is set to one. as the last step in the conversion sequence, the one-unit capacitor will be switched fro v l to v h . the second one-unit capacitor remains connected to v l throughout the con- version sequence. the following circuit is for the last conversion step: the charge is now written as follows: q = 8(v h C v i ) + 2(v h C v i ) + 1 (v h C v i ) C 5 v i q = 8 v h + 2 v h + 1 v h C 8 v i C 2 v i C 1 v i C 5 v i q = 11 v h C 16v i charge conservation yields the following results: 21/2 v h = 11 v h C 16 v i 16 v i = 11 v h C 21/2 v h 16 v i = 1/2 v h v i = 1/32 v h which is positive. since the output of the comparator is now a logic zero, the lsb of the sar is cleared to zero. because the conversion is complete, it is not necessary to switch the one-unit capacitor back to v l . the digital result of this example conversion is 1010 2 . in the previous example, an analog input voltage of 21/32 v h yields a digital result of 1010 2 or 10/16 v h . an error occurred even though ideal components and conditions were assumed. a closer look at an even simpler 2-bit a/d explains the reason. if the second one-unit capacitor is omitted, the following circuit results: v h + C v l 1 2 4 8 1 v l v i
m68hc11 analog-to-digital converter system motorola reference manual 12-7 the transfer characteristic of the circuit is as follows: without the extra one-unit capacitor, each unit of capacitance corresponds to one-third the total rather than corresponding to the desired one-fourth. when the second one- unit capacitor is added, the following circuit and transfer characteristics result: an analog input of 1/4 v h produces a digital result of 01 2 or 1/4 v h , but an analog input of 1/8 v h yields a digital result of 00 2 or 0.0 v, which is in error by 1/8 v h or 1/2 lsb. this quantization error is an unavoidable consequence of any a/d converter. this par- ticular 2-bit a/d has a quantization error of C0/+1 lsb. a more desirable specification is 1/2 lsb quantization error, as is the case on the MC68HC11a8. quantization error is always a total of 1 lsb, and many manufacturers do not include this error in speci- fications of a/d accuracy. in an all-capacitive charge-redistribution converter, a simple method exists for shifting the transfer characteristic down by 1/2 lsb to center the quantization error. a half-unit capacitor is connected to v h during the sample time and is switched to v l for the re- mainder of the conversion sequence. figure 12-2 demonstrates how this technique is applied to the previously described 2-bit converter. + C v l 1 2 v l v h v h v h v l 11 10 01 00 analog input binary result 1 3 2 3 + C v l 1 2 v l 1 v h v h v l 11 10 01 00 analog input binary result 3 4 v h 1 2 v h 1 4
motorola analog-to-digital converter system m68hc11 12-8 reference manual the charge obtained during the sample time is q s = 4(v x C v l ) + 1/2(v h C v l ) assuming v l = 0 simplifies the equation to q s = 4 v x + 1/2 v h
m68hc11 analog-to-digital converter system motorola reference manual 12-9 (a) sample mode (b) hold mode (c) approximation mode figure 12-2 charge-redistribution a/d with 1/2 lsb quantization error v x + C v i 1 2 1 v l v l 1 2 + C v l v i 1 2 v l 1 2 1 + C v h v l v i bit 1 1 bit 0 sar 1 0 1 0 2 1 v l v l 1 2
motorola analog-to-digital converter system m68hc11 12-10 reference manual the effect of the half-unit capacitor becomes apparent when v i is calculated for the circuit corresponding to a digital result of 01 2 . the equivalent circuit is the charge is now written as follows: q = 1 (v h C v i ) C 3-1/2 v i q = v h C 4-1/2 v i charge conservation yields the following results: 4 v x + 1/2 v h = v h C 4-1/2 v i 4-1/2 v i = v h C 1/2 v h C 4 v x 4-1/2 v i = 1/2 v h C 4 v x 9 v i = 1 v h C 8 v x 9/8 v i = 1/8 v h C v x the comparator only outputs a logic one when v i is less than zero, which is when v x is greater than 1/8 v h . next, v i is calculated for the circuit corresponding to a digital result of 10 2 . the equiv- alent circuit is as follows: + C v i 1 2 1 v l v l v h 1 2
m68hc11 analog-to-digital converter system motorola reference manual 12-11 the charge is written as follows: q = 2(v h C v i ) C 2-1/2 v i q = 2 v h C 4-1/2 v i change conservation yields the following results: 4 v x + 1/2 v h = 2 v h C 4-1/2 v i 4-1/2 v i = 2 v h C 1/2 v h C 4 v x 4-1/2 v i = 3/2 v h C 4 v x 9 v i = 3 v h C 8 v x 9/8 v i = 3/8 v h C v x the comparator only outputs a logic one when v i is less than zero, which is when v x is greater than 3/8 v h . the complete transfer characteristic for the 2-bit a/d with the new half-unit capacitor is the user should note that there is no 2-bit digital code for 4/4 v h (full scale). + C v i 1 2 1 v l v l v h 1 2 v h v h v l 11 10 01 00 analog input binary result 3 4 v h 1 2 v h 1 4
motorola analog-to-digital converter system m68hc11 12-12 reference manual 12.2 a/d converter implementation on MC68HC11a8 the a/d converter in the MC68HC11a8 is composed of a single successive-approxi- mation charge-redistribution a/d converter and digital control circuitry. the analog section is somewhat more complex than the circuits previously described but identical charge-redistribution principles are used. the digital section consists of the logic that makes the a/d work as a system with the rest of the microcontroller unit (mcu). 12.2.1 MC68HC11a8 successive-approximation a/d converter a discussion of the actual converter in the MC68HC11a8 is presented in the following paragraphs. figure 12-3 shows the successive-approximation converter of the MC68HC11a8 a/d in sample mode. unlike earlier examples, the weighted capacitor array has a series capacitor (c s ) sep- arating the low-order half of the array from the high-order half. this capacitor effective- ly divides the value of the low-order capacitors to the left by 16, which simplifies the layout of the weighted capacitor array and assures better matching of capacitance siz- es. figure 12-3 MC68HC11a8 a/d in sample mode except the half-unit and 1.1-unit elements, all capacitors are composed of connected groups of one-unit capacitors, which minimizes errors caused by sizing and process- ing. in the MC68HC11a8, these capacitors consist of polysilicon plates separated by an inter-level oxide; the lower plates are isolated from the substrate by a second layer of oxide. the capacitance of this structure is not subject to variation due to voltages on the plates relative to the substrate. in the MC68HC11a8 a/d, both inputs and the output of the comparator are shorted together during the sample time, which causes all three points to stabilize at the trip voltage of the comparator; thus, comparator offsets are effectively cancelled out of the v x + C v i 2 1 1 v l v h 1 2 8 4 2 1 8 4 1 . 1 c s 16 v trip
m68hc11 analog-to-digital converter system motorola reference manual 12-13 calculations. after the sample period, the shorting paths are disconnected, and the conversion sequence proceeds as in the earlier examples. the 16-unit capacitor from the plus input of the comparator to v l is not critical in terms of size because it is only used to hold the plus input at v trip during the short conversion time. 12.2.2 a/d charge pump and resistor-capacitor (rc) oscillator a charge pump on the chip develops about 7 or 8 v, and this high voltage is used to drive the gates of the analog switches in the input multiplexer and capacitor array. this high gate voltage assures low source to drain impedance for analog signals up to and including v dd . in fact, v rh can be somewhat higher than v dd (approximately 6 v), and the converter will still yield good ratiometric results. the a/d charge pump is disabled coming out of reset and is turned on by setting the a/d power-up (adpu) control bit in the option control register before the a/d system can be used. a delay is required after turning on adpu to allow the charge pump and comparator circuits to stabilize before using the converter system. the charge-redistribution a/d process is a dynamic process in that the charge on the capacitor array will eventually leak off. this capacitor array is part of an internal digital- to-analog converter (dac), which means the conversion process must be completed within a reasonable time after the sample time ends. the other circuitry on the mcu is static to allow very low clock frequencies, thus saving power. at bus frequencies (e clock) below 750 khz, the e clock should not normally be used as the a/d conversion clock because there is a risk of error due to charge leakage at temperature extremes. laboratory characterization has indicated good performance at e-clock rates as low as 10 khz, but the specification has been guard banded against process variations. an on-chip rc oscillator provides an alternate clocking source for the a/d system when the e clock is running too slow to assure good conversions. this clock source is selected by writing a one to the clock select (csel) control bit in the option control register. the a/d clock (e clock or rc oscillator depending on csel) drives the sar sequencer and the a/d charge pump. some delay may be required after switching clock sources, depending on their frequencies. the rc oscillator frequency varies with processing but is typically about 2 mhz. when the e clock is being used as the a/d clock source, the conversion sequence is inherently synchronized to the main mcu clocks. using the e clock has two advantag- es over using the rc oscillator, which is asynchronous to system clocks. first, the comparator output is sampled at relatively quiet times in the system clock cycle, thus reducing the effects of internal mcu noise. when the rc oscillator is being used, there is more error attributable to internal system clock noise. second, result-register up- dates automatically occur during a portion of the system clock cycle where reads do not occur; thus, an update cannot interfere with a read. when the rc oscillator is used, there is no conflict between updates and reads, but there is an additional synchroni- zation delay imposed at the end of each channel conversion to allow for synchroniza- tion to the system e clock. the following illustration shows the option control register for reference since the
motorola analog-to-digital converter system m68hc11 12-14 reference manual adpu and csel control bits affect the a/d converter system. the csel control bit also selects an alternate clock source for the on-chip eeprom charge pump. this charge pump is separate from the a/d charge pump, but both pumps are selected with the csel control bit. in the case of the a/d charge pump, csel needs to be one when the e clock is too slow to assure that the successive-ap- proximation sequence will finish before any significant charge loss. in the case of the eeprom, the efficiency of the charge pump is at issue. more details on eeprom charge-pump efficiency are presented in section 4 on-chip memory . when the e clock is at or above 2 mhz, csel should always be zero; when the e clock is below 750 khz, csel should almost always be one. at e-clock frequencies between 750 khz and 2 mhz, csel should be set to one for eeprom programming and erase operations so the eeprom charge pump works more efficiently; however, csel should be set to zero for a/d conversions to assure highest a/d accuracy by reducing the effects of on-chip noise. in most applications, switching csel on and off is not necessary. instead, a trade-off can usually be made on the basis of application requirements. for example, the addi- tional a/d error attributable to internal noise when csel equals one is on the order of 1/2 lsb, which is acceptable in many applications. 12.2.3 MC68HC11a8 a/d system control logic the a/d system on the MC68HC11a8 consists of a single successive-approximation a/d converter, an input multiplexer to select one of 16 channels (including eight chan- nels associated with pins on the mcu), and sophisticated control circuitry to configure and control conversion activities. four separate result registers are included with con- trol logic that implements automatic conversion sequences on a selected channel four times or on four channels (once each). conversion sequences are configured to re- peat continuously or to stop after one set of four conversions. an on-chip rc oscillator is selected to allow normal operation of the a/d when very low mcu clock frequencies are being used. figure 12-4 shows the timing for a sequence of four a/d conversions; the system e clock is being used as the conversion clock, which is the normal case. the a/d con- verter is dynamic in that the charge attained during the sample period will eventually leak off the dac capacitors. if the system e clock is slower than 750 khz, an on-chip rc oscillator should be selected as the a/d conversion clock source. the rc clock source is selected by setting the csel control bit in the option register. since the rc clock source is asynchronous to the mcu e clock, a synchronization delay is re- quired at the end of each conversion in the sequence to prevent result-register up- dates in the same part of the e-clock cycle where a read is taking place. a/d result registers should not normally be used before the conversion complete flag (ccf) is option system configuration options $1039 bit 7 654321 bit 0 adpu csel irqe dly cme cr1 cr0 reset: 00010000
m68hc11 analog-to-digital converter system motorola reference manual 12-15 set at the end of the fourth conversion in a sequence because of uncertainty in the ex- act frequency of the on-chip rc oscillator and because of synchronization delays. when the e clock is being used as the conversion clock, figure 12-4 can be used to determine the earliest availability of valid data in result registers 3C1. for example, adr1 has valid conversion results 34 e-clock cycles after the a/d control/status reg- ister is written. figure 12-4 timing diagram for a sequence of four a/d conversions 12.2.4 a/d control/status register (adctl) all bits in this register may be read or written except bit 7, which is a read-only status indicator, and bit 6, which always reads zero. bit 7 is cleared by reset, but the other bits are not affected by reset. the following register and paragraphs describe the func- tion of each bit. ccf conversions complete flag this read-only status indicator is set when all four a/d result registers contain valid conversion results. each time the adctl register is written, this bit is automatically cleared, and a new conversion sequence is started immediately. in the continuous scan modes, conversions continue in round-robin fashion, and the result registers are updated with current data even though the ccf bit remains set. note the user must write to the adctl register to initiate conversion oper- ations. to abort a conversion operation in progress, write to the adctl register, and a new conversion operation is initiated immediately. adctl a/d control/status register $1030 bit 7 654321 bit 0 ccf scan mult cd cc cb ca reset: 0 0 uuuuuu 0 32 64 96 128 e cycles sample analog input successive approximation sequence msb 4 cycles bit 6 2 cyc bit 5 2 cyc bit 4 2 cyc bit 3 2 cyc bit 2 2 cyc bit 1 2 cyc lsb 2 cyc 2 cyc end repeat sequence, scan = 1 set cc flag convert first channel, update adr1 convert second channel, update adr2 convert third channel, update adr3 convert fourth channel, update adr4 12 e cycles write to adctl e clock
motorola analog-to-digital converter system m68hc11 12-16 reference manual bit 6 not implemented; always reads zero. scan continuous scan control when this bit is zero, the four requested conversions are performed, once each, to fill the four result registers. when this bit is one, conversions continue in a round-robin fashion with the result registers being updated as new data becomes available. mult multiple-channel/single-channel control when this bit is zero, the a/d system is configured to perform four consecutive con- versions on the single channel specified by the four channel-select bits (cd:ca of the adctl register). when this control bit is one, the a/d system is configured to perform conversions on each channel in the group of four channels specified by the cd and cc channel-select bits. in this multiple-channel mode, each channel is associated with a specific result register. cd, cc, cb, ca channel selects these four channel-select bits are used to specify the channel(s) to be operated on for an a/d conversion operation. table 12-1 shows the relationship between the cd-ca bits and the channel(s) to be operated on. when a multiple-channel mode is selected (mult = 1), the cb and ca selects have no effect, and the group of four channels af- fected are selected by cd and cc. the last group of four analog channels is used during factory testing of the mcu. the 1/2 v rh channel is misleading in that there is no internal voltage divider actually divid- ing the reference supply. rather, a result of 1/2 v rh is artificially produced by special table 12-1 a/d channel assignments cd cc cb ca channel signal result in adrx if mult = 1 0000 pe0 adr1 0001 pe1 adr2 0010 pe2 adr3 0011 pe3 adr4 0100 pe4* adr1 0101 pe5* adr2 0110 pe6* adr3 0111 pe7* adr4 1000 reserved adr1 1001 reserved adr2 1010 reserved adr3 1011 reserved adr4 1100 v h ** adr1 1101 v l ** adr2 1110 1/2 v h ** adr3 1111 reserved** adr4 *not available in 48-pin package versions. **these channels intended for factory testing.
m68hc11 analog-to-digital converter system motorola reference manual 12-17 control logic, which forces unusual connections of the dac capacitors during sample time. thus, the charge attained will be identical to that obtained by sampling an analog level of 1/2 v rh on one of the eight analog input pins. 12.2.5 a/d result registers (adr[4:1]) the a/d result registers are read-only registers used to hold an 8-bit conversion result. after all four result registers have been filled with valid data in a conversion sequence, the ccf status bit is set to indicate the results are valid. new conversion results are calculated in the a/d logic and are transferred into the result registers in a part of the clock cycle where reads do not take place; therefore, no interference occurs between software reads and result updates. 12.3 a/d pin connection considerations since there are no p-channel devices directly connected to the a/d input or reference pins, voltages above v dd do not pose a latchup threat. if an a/d input rises above the threshold of the protection device, an input protection device avalanches, and current into this device should be limited. because of an inherent diode to v ss , a/d inputs must not go below v ss , or the input can be permanently damaged. a series resistor of 1k w will prevent damage, but avoid a series resistor of more than 10 k w because input leakage acting through this impedance will degrade a/d accuracy. external clamping diodes on a/d inputs should be avoided because the leakage through these devices is greater than the input pin leakage current and could significantly degrade accuracy if significant resistance exists in series with the analog source. figure 12-5 shows a model of an a/d input pin, which is useful in planning external circuitry and connec- tions. figure 12-5 electrical model of an a/d input pin (sample mode) capacitors from a/d inputs to v rl help prevent errors due to system noise, but it is important to size these capacitors properly for the way the a/d converter is being used in a particular system. factors affecting the size of these capacitors are as follows: 1. source impedance of the analog signal 2. rate of change of the analog signal diffusion/poly < 2 pf coupler 400 na junction leakage + ~20v C ~0.7v * * this analog switch is closed only during the 12-cycle sample time. v rl input + ~12v C ~0.7v protection device 4 k w dummy n-channel output device analog input pin ~ 20 pf dac capacitance
motorola analog-to-digital converter system m68hc11 12-18 reference manual 3. electrical model of the a/d inputs 4. frequency of a/d conversion requests to the particular channel 5. analog level on the previously converted channel (in some cases) the first three factors are straightforward, but the last two factors are subtle. figure 12-4 and figure 12-5 should be used in conjunction with the following discussion. the maximum external source impedance of an analog signal is limited by the leakage into the pin (see figure 12-5 ). when v rh Cv rl = 5.12 v, 1 lsb corresponds to 20 mv of input voltage. the worst-case input leakage of 400 na acting through 10 k w of external series resistance will result in about 0.2 lsbs of offset. although the specifi- cation states the maximum-allowable external series resistance is 10 k w , a higher source impedance can be used, but it may cause additional errors in the results. the leakage current arises from n-channel junction leakages that are worse at high tem- peratures. since only n-channel devices contribute to this current, it is unidirectional toward v ss and will only cause errors, lowering a/d results below the expected value. the minimum-desirable source impedance for an analog input signal should ensure the current at the a/d pin never gets high enough to cause cmos latchup. the hc- mos process used on the MC68HC11a8 is much more robust than older 14xxx-style cmos, but the current at a pin should still be limited to 25 ma or less. although the pins can withstand much more, 25 ma is considered a good design target. the source impedance that meets this limitation will depend on the total system. for example, suppose the worst-case scenario for a particular system results in an analog source accidentally shorting to C12 v. the inherent internal diodes to v ss will clamp the volt- age at the pin to about C0.7 v. this clamped voltage means a maximum current of 25 ma must cause 11.3 v to be dropped across a series-limiting resistance, which calcu- lates to 452 w . however, some guard band should be allowed for tolerances on the clamped voltage, the source voltages, the resistor, etc. note two of the most common a/d application errors have been either too much source impedance, resulting in higher-than-expected errors, or too little source impedance, resulting in permanent damage to a/d inputs. the most common cause of damage to a/d inputs is a very low source impedance to a negative voltage, which is more than 1 v below v ss . the rate of change of the analog input signal is important if an external low-pass filter is used to increase noise immunity. if too large an rc time constant is chosen for the external filter, meaningful transitions may be filtered out of analog signal source. an external lowpass filter also introduces a delay between the analog source and the a/ d input pin. if the a/d system is used to locate a timing reference to a peak level on an analog input signal, this delay must be considered. if the input to a channel changes drastically between successive samples in a sequence of conversions, a charge-share mechanism can affect the accuracy of the result as described in the following para- graphs. this charge-share mechanism is normally only visible in multiple-channel, continuous-scan conversion sequences where two adjacent channels are connected
m68hc11 analog-to-digital converter system motorola reference manual 12-19 to grossly different analog levels. a subtle aspect of figure 12-5 is that the dac capacitance is shared by all conver- sions. this aspect results in the initial voltage on the dac capacitance, just before a sample period, being approximately equal to the voltage on the last channel convert- ed. for individual conversions, this result usually does not produce any observable ef- fect because the charge stored in the internal dac capacitance is so small. consider what happens when a multiple-channel, continuous-scan conversion operation is oc- curring (mult and scan = 1). for an e-clock rate of 2 mhz, a particular channel is sampled once every 64 m s. each time, the initial voltage on the dac capacitance just before the sample is equal to the voltage on the previously sampled channel. over 15,000 times a second a small amount of charge is removed from or added to the ex- ternal capacitance on the pin. the charge is restored by charging or discharging through the external source impedance. for some values of external r and c, the charge added during the sample time cannot be fully bled off through the external rc before the next sample time occurs. this problem causes a stair-step building of charge in the external capacitance that builds until an equilibrium is reached, in which the amount of charge added during a sample time is exactly offset by the charge bled off during the period between samples. this condition is a secondary effect, which sel- dom results in more than an lsb of error (even in the most extreme case). after study- ing the mechanism, it should be fairly easy to avoid problems from this effect by careful choice of the external r and c values, by avoiding channel assignments resulting in grossly different levels on adjacent critical channels, and/or by avoiding the multiple- channel, continuous-scan conversion modes when a high-frequency e clock is being used. three types of cases must be considered, which result from the interaction of an ex- ternal rc filter and the internal model of an a/d input pin. the method of determining the error expected from a particular choice of external component values depends on which of the three cases applies. errors arise from leakage current acting through the external series resistance or from system noise. if a very large external series imped- ance is used, a problem can arise where the internal dac capacitance cannot be prop- erly charged within the 12-cycle sample time; however, errors due to simple leakage through the external resistance usually do not allow using a large enough external re- sistance to cause this effect. the following paragraphs describe the cases of interac- tion of an external filter to the input model. the first case arises when the external time constant is small compared to the length of the 12-cycle sample period. in this case, all residual charge on the internal dac ca- pacitance is dissipated, and the pin settles at the expected voltage before the end of the sample time. the problem with this case is that a filter with such a short time con- stant provides very little filtering. in this case no errors result; thus, no calculations are needed. the second case arises when the external time constant is long compared to the sam- ple period but is relatively short compared to the period between samples. in this case, the residual charge on the internal dac capacitance is redistributed to the external ca- pacitance during the sample, but this charge is not dissipated through the external re-
motorola analog-to-digital converter system m68hc11 12-20 reference manual sistance before the end of the sample time. this condition results in a small error in the sample, but this charge is dissipated before the next sample of this channel. thus, no accumulated error occurs. in cases of this second type, the primary governing fac- tor is the redistribution of the residual charge from the internal dac capacitance. usu- ally, the external capacitance is so much larger than the internal dac capacitance that the voltage change due to charge redistribution reduces to the difference between the previous channel voltage and the current channel voltage times the ratio of the internal dac capacitance to the external capacitance. some of this charge is dissipated before the end of the sample period by the external rc time constant. figure 12-6 is a graph- ic estimation of the amount of error resulting in such a case. errors of this type are present even in single-pass conversion sequences but rarely cause noticeable errors. in figure 12-6 , the solid waveform [4] is the graphic estimation of the analog level at an a/d input. this waveform results from the simultaneous operation of charge redis- tribution of the residual charge on the internal dac capacitance just before the sample period began at to and from the dissipation of this charge through the external rc net- work. waveform [2] has a time constant, t80 ns, based on the model of an a/d input. the peak level [1] is (v a C v b ) x (c i ? (c x + c i )) where v a = the analog level driving the previously sampled channel v b = the level driving the currently sampled channel c i = the internal dac capacitance c x = the external capacitance
m68hc11 analog-to-digital converter system motorola reference manual 12-21 figure 12-6 graphic estimation of analog sample level (case 2) waveform [3] is the familiar rc exponential decay through the external network, and it is assumed that the external capacitance is very large compared to the 20 pf dac capacitance. the time, t 1 , marks the end of the 12-cycle sample period, and level [5] is the level that will be captured, held, and converted even though the pin voltage con- tinues to decay through the external network. the third case arises when the external time constant is very long compared to the time between samples. in this case, the residual charge redistributed during the first sample is not completely dissipated before the next sample; thus, there is an accumu- lation of charge. this accumulation causes increasing errors on successive samples until equilibrium is reached between the charge added during a sample and the charge dissipated between samples. errors caused by cases of this third type are often mis- interpreted as leakage between adjacent channels. the magnitude of this type error is estimated by developing equations for voltage change caused by charge added dur- ing a sample time and voltage change caused by the action of the external rc be- tween successive samples. these two equations are set equal to each other, and the equilibrium voltage can then be resolved. the voltage change during the sample is controlled by the ratio of the internal dac capacitance to the external capacitance (as in the previous case), but the external rc is assumed to be so long that it produces no significant effect until after the sample time ends. the voltage change between samples results from a simple rc exponen- tial decay. to illustrate the estimation of errors resulting from a case-three situation, consider this example. the e-clock rate equals 2 mhz, v rh equals 5.12 v, v rl equals 0.0 v, chan- nel one is connected to a 5.12-v analog level, and channel 2 is connected to a 0-v [1] [2] [3] [4] [5] t 1 t 0 0 . 0 v time pin voltage
motorola analog-to-digital converter system m68hc11 12-22 reference manual analog level. the external series resistance is 10 k w , and the external capacitance is 0.01 m f. the value $30 is written to the adctl register to initiate continuous round- robin conversion of channels 0, 1, 2, and 3. the following circuit is a model of the cir- cuitry under investigation: r x and c x are the external components, c i is the internal dac capacitance, and r i is the internal series resistance (includes n-channel couplers and polysilicon intercon- nections). from figure 12-5 ,c i is 20 pf and r i is 4 k w . the switch represents an analog switch closed only during the sample time. for the chosen e-clock rate, the sample time is 6 m s, and the period from one sample to the next sample of the same channel is 64 m s. the voltage change due to redistribution of the residual charge on the dac capaci- tance, which is left from conversion of the previous channel, is written as d v samp = (v 1 C v 2 ) [c i ? (c x + c i )] where v 1 = 5.12 v and v 2 = 0.0 v d v samp ? 5.12 (20 pf ? 0.01 m f) v d v samp ? 10 mv not all of this voltage decays before the second sample; thus, there is an accumulation of error until an equilibrium is reached. since this equilibrium voltage is very small rel- ative to the (v 1 Cv 2 ) term of this equation, the d v samp value does not change signif- icantly between the first sample and a sample time when equilibrium is reached. since c x is so large relative to c i , c i is ignored in the (c x + c i ) term. the voltage change between samples of channel 2 is a simple exponential decay through the external rc, which is written as d v hold = (v eq C v 2 )(1 C e C t/rxcx ) where v eq is the equilibrium voltage d v hold = v eq (1 C e C 64 m s/10k 0.01 m f ) dac capacitance v rl analog input (pe2 pin) ~ 20 pf 0.01 m f diffusion and poly coupler 10 k w 4 k w v rl r x c x r i c i analog level (0.0 v) components within mcu
m68hc11 analog-to-digital converter system motorola reference manual 12-23 d v hold = v eq (1 C e C 0.64 ) d v hold = 0.473 v eq when equilibrium is reached, the voltage gained during a sample is equal to the volt- age lost between samples. therefore, set d v hold equals d v samp and solve for v eq : 0.473 v eq = 10 mv v eq = 10 mv/0.473 ? 21 mv this value amounts to almost one lsb of error. if the external capacitance is changed to 0.1 m f, the error attributable to this effect becomes approximately 1 mv. as the ex- ternal capacitance is changed, two changes occur: first, the time constant of the exter- nal rc changes; second, the ratio of the external capacitance to the dac capacitance changes. because these two changes influence the result at different rates, it is not practical to make a general statement about the amount of influence versus the change in the external capacitance. for external series resistances not exceeding the recommended limit of 10 k w , the er- rors attributable to this effect are very small. however, if the external series resistance is increased to 100 k w and small capacitance values are used, the errors can become serious. for example, an external rc of 100 k w and 0.001 m f would cause errors of about 200 mv in the previous example (about 10 lsbs). the extra leakage effects are also as much as 40 mv.
motorola analog-to-digital converter system m68hc11 12-24 reference manual
m68hc11 instruction set details motorola reference manual a-1 appendix a instruction set details a.1 introduction this appendix contains complete detailed information for all m68hc11 instructions. the instructions are arranged in alphabetical order with the instruction mnemonic set in larger type for easy reference. a.2 nomenclature the following nomenclature is used in the subsequent de?nitions. a. operators: ( ) = contents of register shown inside parentheses = is transferred to y = is pulled from stack ? = is pushed onto stack ? = boolean and + = arithmetic addition symbol except where used as inclusive- or symbol in boolean formula ? = exclusive or = multiply : = concatenation - = arithmetic subtraction symbol or negation symbol (twos complement) b. registers in the mpu acca = accumulator a accb = accumulator b accx = accumulator acca or accb accd = double accumulator accumulator a concatenated with accumulator b where a is the most significant byte ccr = condition code register ix = index register x, 16 bits ixh = index register x, high order 8 bits ixl = index register x, low order 8 bits pc = program counter, 16 bits pch = program counter, high order (most significant) 8 bits pc = program counter, low order (least significant) 8 bits sp = stack pointer, 16 bits sph = stack pointer, high order 8 bits spl = stack pointer, low order 8 bits
motorola instruction set details m68hc11 a-2 reference manual c. memory and addressing m = a memory location (one byte) m+1 = the byte of memory at $0001 plus the address of the mem- ory location indicated by m rel = relative offset (i.e., the twos complement number stored in the last byte of machine code corresponding to a branch in- struction) (opr) = operand (msk) = mask used in bit manipulation instructions (rel) = relative offset used in branch instructions d. bits [7:0] of the condition code register s =stop disable, bit 7 x = x interrupt mask, bit 6 h = half carry, bit 5 i = i interrupt mask, bit 4 n = negative indicator, bit 3 z = zero indicator, bit 2 v = twos complement overflow indicator, bit 1 c = carry/borrow, bit 0 e. status of individual bit before execution of an instruction an = bit n of acca (n = 7, 6, 5... 0) bn = bit n of accb (n = 7, 6, 5... 0) dn = bit n of accd (n = 15, 14, 13... 0) where bits [15:8] refer to acca and bits [7:0] refer to accb ixn = bit n of ix (n = 15, 14, 13... 0) ixhn = bit n of ixh (n = 7, 6, 5... 0) ixln = bit n of ixl (n = 7, 6, 5... 0) iyn = bit n of iy (n = 15, 14, 13... 0) iyhn = bit n of iyh (n = 7, 6, 5... 0) iyln = bit n of iyl (n = 7, 6, 5... 0) mn = bit n of m (n = 7, 6, 5... 0) sphn = bit n of sph (n = 7, 6, 5... 0) spln = bit n of spl (n = 7, 6, 5... 0) xn = bit n of x (n = 7, 6, 5... 0) f. status of individual bit of result of execution of an instruction (i) for 8-bit results: rn = bit n of the result (n = 7, 6, 5... 0). this applies to instructions which provide a result contained in a single byte of memory or in an 8-bit register. (ii) for 16-bit results: rhn = bit n of the most significant byte of the result (n = 7, 6, 5... 0) rln = bit n of the least significant byte of the result (n = 7, 6, 5... 0). this applies to instructions which provide a result con- tained in two consecutive bytes of memory or in a 16-bit reg- ister.
m68hc11 instruction set details motorola reference manual a-3 rn = bit n of the result (n = 15, 14, 13... 0) g. notation used in ccr activity summary figures = bit not affected 0 = bit forced to zero 1 = bit forced to one d = bit set or cleared according to results of operation ? = bit may change from one to zero, remain zero, or remain one as a result of this operation, but cannot change from zero to one. h. notation used in cycle-by-cycle execution tables = irrelevant data ii = one byte of immediate data jj = high-order byte of 16-bit immediate data kk = low-order byte of 16-bit immediate data hh = high-order byte of 16-bit extended address ll = low-order byte of 16-bit extended address dd = low-order eight bits of direct address $0000C$00ff (high byte assumed to be $00) mm = 8-bit mask (set bits correspond to operand bits which will be affected) ff = 8-bit forward offset $00 (0) to $ff (255) (is added to index) rr = signed relative offset $80 (C128) to $7f (+127) (offset rela- tive to address following machine code offset byte) op = address of opcode byte op+n = address of n th location after opcode byte sp = address pointed to by stack pointer value (at the start of an instruction) sp+n = address of n th higher address past that pointed to by stack pointer spCn = address of n th lower address before that pointed to by stack pointer sub =address of called subroutine nxt op = opcode of next instruction rtn hi = high-order byte of return address rtn lo = low-order byte of return address svc hi = high-order byte of address for service routine svc lo = low-order byte of address for service routine vec hi = high-order byte of interrupt vector vec lo = low-order byte of interrupt vector
motorola instruction set details m68hc11 a-4 reference manual aba add accumulator b to accumulator a aba operation: acca (acca) + (accb) description: adds the contents of accumulator b to the contents of accumulator a and places the result in accumulator a. accumulator b is not changed. this instruction affects the h condition code bit so it is suitable for use in bcd arithmetic operations (see daa instruction for additional information). condition codes and boolean formulae: h a3 ? b3 + b3 ? r3 + r3 ? a3 set if there was a carry from bit 3; cleared otherwise. nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v a7 ? b7 ? r7 + a7 ? b7 ? r7 set if a twos complement overflow resulted from the operation; cleared otherwise. c a7 ? b7 + b7 ? r7 + r7 ? a7 set if there was a carry from the msb of the result; cleared otherwise. source forms: aba addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d dddd cycle aba (inh) addr data r/ w 1op1b 1 2 op+1 1
m68hc11 instruction set details motorola reference manual a-5 abx add accumulator b to index register x abx operation: ix (ix) + (accb) description: adds the 8-bit unsigned contents of accumulator b to the contents of index register x (ix) considering the possible carry out of the low-order byte of the index register x; places the result in index register x (ix). accumulator b is not changed. there is no equivalent instruction to add accumulator a to an index register. condition codes and boolean formulae: none affected source forms: abx addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle abx (inh) addr data r/ w 1op3a 1 2 op+1 1 3 ffff 1
motorola instruction set details m68hc11 a-6 reference manual aby add accumulator b to index register y aby operation: iy (iy) + (accb) description: adds the 8-bit unsigned contents of accumulator b to the contents of index register y (iy) considering the possible carry out of the low-order byte of the index register y; places the result in index register y (iy). accumulator b is not changed. there is no equivalent instruction to add accumulator a to an index register. condition codes and boolean formulae: none affected source forms: aby addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle aby (inh) addr data r/ w 1op1b 1 2 op+1 3a 1 3 op+2 1 4 ffff 1
m68hc11 instruction set details motorola reference manual a-7 adc add with carry adc operation: accx (accx) + (m) + (c) description: adds the contents of the c bit to the sum of the contents of accx and m and places the result in accx. this instruction affects the h condition code bit so it is suitable for use in bcd arithmetic operations (see daa instruction for addition- al information). condition codes and boolean formulae: h x3 ? m3 + m3 ? r3 + r3 ? x3 set if there was a carry from bit 3; cleared otherwise. nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v x7 ? m7 ? r7 + x7 ? m7 ? r7 set if a twos complement overflow resulted from the operation; cleared otherwise. c x7 ? m7 + m7 ? r7 + r7 ? x7 set if there was a carry from the msb of the result; cleared otherwise. source forms: adca (opr); adcb (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d dddd cycle adca(imm) adca (dir) adca (ext) adca (ind,x) adca (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 89 1 op 99 1 op b9 1 op a9 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 a9 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1 cycle adcb (imm) adcb (dir) adcb (ext) adcb (ind,x) adcb (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op c9 1 op d9 1 op f9 1 op e9 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 e9 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1
motorola instruction set details m68hc11 a-8 reference manual add add without carry add operation: accx (accx) + (m) description: adds the contents of m to the contents of accx and places the result in ac- cx. this instruction affects the h condition code bit so it is suitable for use in bcd arithmetic operations (see daa instruction for additional information). condition codes and boolean formulae: h x3 ? m3 + m3 ? r3 + r3 ? x3 set if there was a carry from bit 3; cleared otherwise. nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v x7 ? m7 ? r7 + x7 ? m7 ? r7 set if a twos complement overflow resulted from the operation; cleared otherwise. c x7 ? m7 + m7 ? r7 + r7 ? x7 set if there was a carry from the msb of the result; cleared otherwise. source forms: adda (opr); addb (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d dddd cycle adda(imm) adda (dir) adda (ext) adda (ind,x) adda (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op bb 1 op 9b 1 op bb 1 op ab 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ab 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1 cycle addb (imm) addb (dir) addb (ext) addb (ind,x) addb (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op cb 1 op db 1 op fb 1 op eb 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 eb 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1
m68hc11 instruction set details motorola reference manual a-9 addd add double accumulator addd operation: accd (accd) + (m : m + 1) description: adds the contents of m concatenated with m + 1 to the contents of accd and places the result in accd. accumulator a corresponds to the high-order half of the 16-bit double accumulator d. condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. v d15 ? m15 ? r15 + d15 ? m15 ? r15 set if a twos complement overflow resulted from the operation; cleared otherwise. c d15 ? m15 + m15 ? r15 + r15 ? d15 set if there was a carry from the msb of the result; cleared otherwise. source forms: addd (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle addd (imm) addd (dir) addd (ext) addd (ind,x) addd (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op c3 1 op d3 1 op f3 1 op e3 1 op 18 1 2 op+1 jj 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 e3 1 3 op+2 kk 1 00dd (00dd) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 ffff 1 00dd+1 (00dd+1 ) 1 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 hhll+1 (hhll+1) 1 x+ff+ 1 (x+ff+1 ) 1 y+ff (y+ff) 1 6 ffff 1 ffff 1 y+ff+ 1 (y+ff+1 ) 1 7 ffff 1
motorola instruction set details m68hc11 a-10 reference manual and logical and and operation: accx (accx) + (m) description: performs the logical and between the contents of accx and the contents of m and places the result in accx. (each bit of accx after the operation will be the logical and of the corresponding bits of m and of accx before the operation.) condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v0 cleared source forms: anda (opr); andb (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle anda(imm) anda (dir) anda (ext) anda (ind,x) anda (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 84 1 op 94 1 op b4 1 op a4 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ab 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1 cycle andb (imm) andb (dir) andb (ext) andb (ind,x) andb (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op c4 1 op d4 1 op f4 1 op e4 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 eb 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1
m68hc11 instruction set details motorola reference manual a-11 asl arithmetic shift left asl (same as lsl) operation: description: shifts all bits of the accx or m one place to the left. bit 0 is loaded with a zero. the c bit in the ccr is loaded from the most significant bit of accx or m. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. vn ? c = [n ? c] + [ n ? c] (for n and c after the shift) set if (n is set and c is clear) or (n is clear and c is set); cleared otherwise (for values of n and c after the shift). cm7 set if, before the shift, the msb of accx or m was set; cleared otherwise. source forms: asla; aslb; asl (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle asla (imm) aslb (dir) asl (ext) asl (ind,x) asl (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 48 1 op 58 1 op 78 1 op 68 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 68 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll result 0 x+ff result 0 ffff 1 7 y+ff result 0 c b7 C C C C C C b0 0
motorola instruction set details m68hc11 a-12 reference manual asld arithmetic shift left double accumulator asld (same as lsld) operation: description: shifts all bits of accd one place to the left. bit 0 is loaded with a zero. the c bit in the ccr is loaded from the most significant bit of accd. condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. vn ? c = [n ? c] + [ n ? c] (for n and c after the shift) set if (n is set and c is clear) or (n is clear and c is set); cleared otherwise (for values of n and c after the shift). c d15 set if, before the shift, the msb of accd was set; cleared otherwise. source forms: asld (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle asld (inh) addr data r/ w 1op05 1 2 op+1 1 3 ffff 1 c b7 C C C C C C b0 b7 C C C C C C b0 0 acca accb
m68hc11 instruction set details motorola reference manual a-13 asr arithmetic shift right asr operation: description: shifts all bits of the accx or m one place to the right. bit 7 is held constant. bit 0 is loaded into the c bit of the ccr. this operation effectively divides a twos complement value by two without changing its sign. the carry bit can be used to round the result. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. vn ? c = [n ? c] + [ n ? c] (for n and c after the shift) set if (n is set and c is clear) or (n is clear and c is set); cleared otherwise (for values of n and c after the shift). cm0 set if, before the shift, the lsb of accx or m was set; cleared otherwise. source forms: asra; asrb; asr (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle asra (imm) asrb (dir) asr (ext) asr (ind,x) asr (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 47 1 op 57 1 op 77 1 op 67 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 68 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll result 0 x+ff result 0 ffff 1 7 y+ff result 0 c b7 C C C C C C b0
motorola instruction set details m68hc11 a-14 reference manual bcc branch if carry clear bcc (same as bhs) operation: pc (pc) + $0002 + rel if (c) = 0 description: tests the state of the c bit in the ccr and causes a branch if c is clear. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bcc (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bcc (inh) addr data r/ w 1op24 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r m68hc11 instruction set details motorola reference manual a-15 bclr clear bit(s) in memory bclr operation: m (m) ? ( pc + 2) m (m) ? ( pc + 3) (for ind,y address mode only) description: clear multiple bits in location m. the bit(s) to be cleared are specified by ones in the mask byte. all other bits in m are rewritten to their current state. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v0 cleared source forms: bclr (opr) (msk) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle bclr (dir) bclr (ind,x) bclr (ind,y) addr data r/w addr data r/w addr data r/w 1 op 15 1 op 1d 1 op 18 1 2 op+1 dd 1 op+1 ff 1 op+1 1d 1 3 00dd (00dd) 1 ffff 1 op+2 ff 1 4 op+2 mm 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 op+2 mm 1 (iy)+ff (y+ff) 1 6 00dd result 0 ffff 1 op+3 mm 1 7 x+ff result 0 ffff 1 8 y+ff result 0
motorola instruction set details m68hc11 a-16 reference manual bcs branch if carry set bcs (same as blo) operation: pc (pc)+ $0002 + rel if (c) = 1 description: tests the state of the c bit in the ccr and causes a branch if c is set. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bcs (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bcs (rel) addr data r/ w 1op25 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r m68hc11 instruction set details motorola reference manual a-17 beq branch if equal beq operation: pc (pc)+ $0002 + rel if (z) = 1 description: tests the state of the z bit in the ccr and causes a branch if z is set. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: beq (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle beq (rel) addr data r/ w 1op27 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r motorola instruction set details m68hc11 a-18 reference manual bge branch if greater than or equal to zero bge operation: pc (pc)+ $0002 + rel if (n) ? (v) = 0 i.e., if (accx) (m) (twos-complement signed numbers) description: if the bge instruction is executed immediately after execution of any of the instructions, cba, cmp(a, b, or d), cp(x or y), sba, sub(a, b, or d), the branch will occur if and only if the twos complement number represented by accx was greater than or equal to the twos complement number represented by m. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bge (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bge (rel) addr data r/ w 1op2c1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r m68hc11 instruction set details motorola reference manual a-19 bgt branch if greater than zero bgt operation: pc (pc)+ $0002 + rel if (z) + [(n) ? (v)] = 0 i.e., if (accx)>(m) (twos-complement signed numbers) description: if the bgt instruction is executed immediately after execution of any of the instructions, cba, cmp(a, b, or d), cp(x or y), sba, sub(a, b, or d), the branch will occur if and only if the twos complement number represented by accx was greater than the twos complement number represented by m. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bgt (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bgt (rel) addr data r/ w 1op2e 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r motorola instruction set details m68hc11 a-20 reference manual bhi branch if higher bhi operation: pc (pc)+ $0002 + rel if (c) + (z) = 0 i.e., if (accx)>(m) (unsigned binary numbers) description: if the bhi instruction is executed immediately after execution of any of the instructions, cba, cmp(a, b, or d), cp(x or y), sba, sub(a, b, or d), the branch will occur if and only if the unsigned binary number represented by accx was greater than unsigned binary number represented by m. generally not useful after inc/dec, ld/st, tst/clr/com because these instructions do not affect the c bit in the ccr. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bhi (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bhi (rel) addr data r/ w 1op22 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r m68hc11 instruction set details motorola reference manual a-21 bhs branch if higher or same bhs (same as bcc) operation: pc (pc)+ $0002 + rel if (c) = 0 i.e., if (accx) 3 (m) (unsigned binary numbers) description: if the bhs instruction is executed immediately after execution of any of the instructions, cba, cmp(a, b, or d), cp(x or y), sba, sub(a, b, or d), the branch will occur if and only if the unsigned binary number represented by accx was greater than or equal to the unsigned binary number represented by m. generally not useful after inc/dec, ld/st, tst/clr/com because these instructions do not affect the c bit in the ccr. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bhs (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bhs (rel) addr data r/ w 1op24 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r motorola instruction set details m68hc11 a-22 reference manual bit bit test bit operation: (accx)?(m) description: performs the logical and between the contents of accx and the contents of m and modifies the condition codes accordingly. neither the contents of accx or m operands are affected. (each bit of the result of the and would be the logical and of the corresponding bits of accx and m.) condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v0 cleared source forms: bita (opr); bitb (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle bita(imm) bita (dir) bita (ext) bita (ind,x) bita (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 85 1 op 95 1 op b5 1 op a5 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ab 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1 cycle bitb (imm) bitb (dir) bitb (ext) bitb (ind,x) bitb (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op c5 1 op d5 1 op f5 1 op e5 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 eb 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1
m68hc11 instruction set details motorola reference manual a-23 ble branch if less than or equal to zero ble operation: pc (pc)+ $0002 + rel if (z) + [(n) ? (v)] = 1 i.e., if (accx) (m) (twos complement signed numbers) description: if the ble instruction is executed immediately after execution of any of the instructions, cba, cmp(a, b, or d), cp(x or y), sba, sub(a, b, or d), the branch will occur if and only if the twos complement signed number represented by accx was less than or equal to the twos complement signed number represented by m. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: ble (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle ble (rel) addr data r/ w 1op2f 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r motorola instruction set details m68hc11 a-24 reference manual blo branch if lower blo (same as bcs) operation: pc (pc)+ $0002 + rel if (c) = 1 i.e., if (accx)<(m) (unsigned binary numbers) description: if the blo instruction is executed immediately after execution of any of the instructions, cba, cmp(a, b, or d), cp(x or y), sba, sub(a, b, or d), the branch will occur if and only if the unsigned binary number represented by accx was less than the unsigned binary number represented by m. generally not useful after inc/ dec, ld/st, tst/clr/com because these instructions do not affect the c bit in the ccr. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: blo (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle blo (rel) addr data r/ w 1op25 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r m68hc11 instruction set details motorola reference manual a-25 bls branch if lower or same bls operation: pc (pc)+ $0002 + rel if (c) + (z) = 1 i.e., if (accx) (m) (unsigned binary numbers) description: if the bls instruction is executed immediately after execution of any of the instructions, cba, cmp(a, b, or d), cp(x or y), sba, sub(a, b, or d), the branch will occur if and only if the unsigned binary number represented by accx was less than or equal to the unsigned binary number represented by m. generally not use- ful after inc/dec, ld/st, tst/clr/com because these instructions do not affect the c bit in the ccr. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bls (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bls (rel) addr data r/ w 1op23 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r motorola instruction set details m68hc11 a-26 reference manual blt branch if less than zero blt operation: pc (pc)+ $0002 + rel if (n) ? (v)= 1 i.e., if (accx)<(m) (twos complement signed numbers) description: if the blt instruction is executed immediately after execution of any of the instructions, cba, cmp(a, b, or d), cp(x or y), sba, sub(a, b, or d), the branch will occur if and only if the twos-complement number represented by accx was less than the twos-complement number represented by m. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: blt (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle blt (rel) addr data r/ w 1op2d1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r m68hc11 instruction set details motorola reference manual a-27 bmi branch if minus bmi operation: pc (pc)+ $0002 + rel if (n) = 1 description: tests the state of the n bit in the ccr and causes a branch if n is set. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bmi (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bmi (rel) addr data r/ w 1op2b 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r motorola instruction set details m68hc11 a-28 reference manual bne branch if not equal to zero bne operation: pc (pc)+ $0002 + rel if (z) = 0 description: tests the state of the z bit in the ccr and causes a branch if z is clear. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: blt (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bne (rel) addr data r/ w 1op26 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r m68hc11 instruction set details motorola reference manual a-29 bpl branch if plus bpl operation: pc (pc)+ $0002 + rel if (n) = 0 description: tests the state of the n bit in the ccr and causes a branch if n is clear. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bpl (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bpl (rel) addr data r/ w 1op2a 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r motorola instruction set details m68hc11 a-30 reference manual bra branch always bra operation: pc (pc)+ $0002 + rel description: unconditional branch to the address given by the foregoing formula, in which rel is the relative offset stored as a twos-complement number in the second byte of machine code corresponding to the branch instruction. the source program specifies the destination of any branch instruction by its abso- lute address, either as a numerical value or as a symbol or expression, that can be numerically evaluated by the assembler. the assembler obtains the relative ad- dress, rel, from the absolute address and the current value of the location counter. condition codes and boolean formulae: none affected source forms: bra (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bra (rel) addr data r/ w 1op20 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r m68hc11 instruction set details motorola reference manual a-31 brclr branch if bit(s) clear brclr operation: pc (pc)+ $0004 + rel if (m) ? (pc + 2) = 0 pc (pc)+ $0005 + rel if (m) ? (pc + 3 ) = 0 (for ind,y address mode only) description: performs the logical and of location m and the mask supplied with the in- struction, then branches if the result is zero (only if all bits corresponding to ones in the mask byte are zeros in the tested byte). condition codes and boolean formulae: none affected source forms: brclr (opr) (msk) (rel) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle brclr (dir) brclr (ind,x) brclr (ind,y) addr data r/w addr data r/w addr data r/w 1 op 13 1 op 1f 1 op 18 1 2 op+1 dd 1 op+1 ff 1 op+1 1f 1 3 00dd (00dd) 1 ffff 1 op+2 ff 1 4 op+2 mm 1 x+ff (x+ff) 1 ffff 1 5 op+3 rr 1 op+2 mm 1 (iy)+ff (y+ff) 1 6 ffff 1 op+3 rr 1 op+3 mm 1 7 ffff 1 op+4 rr 1 8 ffff 1
motorola instruction set details m68hc11 a-32 reference manual brn branch never brn operation: pc (pc)+ $0002 description: never branches. in effect, this instruction can be considered as a two-byte nop (no operation) requiring three cycles for execution. its inclusion in the instruc- tion set is to provide a complement for the bra instruction. this instruction is useful during program debug to negate the effect of another branch instruction without disturbing the offset byte. having a complement for bra is also useful in compiler implementations. condition codes and boolean formulae: none affected source forms: brn (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle brn (rel) addr data r/ w 1op21 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r m68hc11 instruction set details motorola reference manual a-33 brset branch if bit(s) set brset operation: pc (pc)+ $0004 + rel if ( m) ? (pc + 2) = 0 pc (pc)+ $0005 + rel if ( m) ? (pc + 3) = 0 (for ind,y address mode only) description: performs the logical and of location m and the mask supplied with the in- struction, then branches if the result is zero (only if all bits corresponding to ones in the mask byte are ones in the tested byte). condition codes and boolean formulae: none affected source forms: brset (opr) (msk) (rel) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle brset (dir) brset (ind,x) brset (ind,y) addr data r/w addr data r/w addr data r/w 1 op 12 1 op 1e 1 op 18 1 2 op+1 dd 1 op+1 ff 1 op+1 1e 1 3 00dd (00dd) 1 ffff 1 op+2 ff 1 4 op+2 mm 1 x+ff (x+ff) 1 ffff 1 5 op+3 rr 1 op+2 mm 1 (iy)+ff (y+ff) 1 6 ffff 1 op+3 rr 1 op+3 mm 1 7 ffff 1 op+4 rr 1 8 ffff 1
motorola instruction set details m68hc11 a-34 reference manual bset set bit(s) in memory bset operation: m (m)+ (pc + 2) m (m)+ (pc + 3) (for ind,y address mode only) description: set multiple bits in location m. the bit(s) to be set are specified by ones in the mask byte (last machine code byte of the instruction). all other bits in m are unaffected. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v0 cleared source forms: bset (opr) (msk) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd 0 cycle bset (dir) bset (ind,x) bset (ind,y) addr data r/w addr data r/w addr data r/w 1 op 14 1 op 1c 1 op 18 1 2 op+1 dd 1 op+1 ff 1 op+1 1c 1 3 00dd (00dd) 1 ffff 1 op+2 ff 1 4 op+2 mm 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 op+2 mm 1 (iy)+ff (y+ff) 1 6 00dd result 0 ffff 1 op+3 mm 1 7 x+ff result 0 ffff 1 8 y+ff result 0
m68hc11 instruction set details motorola reference manual a-35 bsr branch to subroutine bsr operation: pc (pc)+ $0002 advance pc to return address ? (pcl) push low-order return onto stack sp (sp) C $0001 ? (pch) push high-order return onto stack sp (sp) C $0001 pc (pc) + rel load start address of requested address description: the program counter is incremented by two (this will be the return address). the least significant byte of the contents of the program counter (low-order return address) is pushed onto the stack. the stack pointer is then decremented by one. the most significant byte of the contents of the program counter (high-order return address) is pushed onto the stack. the stack pointer is then decremented by one. a branch then occurs to the location specified by the branch offset. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bsr (rel) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle bsr (rel) addr data r/ w 1op8d1 2 op+1 rr 1 3 ffff 1 4 sub nxt op 1 5 sp rtn lo 0 6 spC1 rtn hi 0
motorola instruction set details m68hc11 a-36 reference manual bvc branch if overflow clear bvc operation: pc (pc)+ $0002 + rel if (v) = 0 description: tests the state of the v bit in the ccr and causes a branch if v is clear. used after an operation on twos-complement binary values, this instruction will cause a branch if there was no overflow. that is, branch if the twos-complement result was valid. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bvc (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bvc (rel) addr data r/ w 1op28 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r m68hc11 instruction set details motorola reference manual a-37 bvs branch if overflow set bvs operation: pc (pc)+ $0002 + rel if (v) = 1 description: tests the state of the v bit in the ccr and causes a branch if v is set. used after an operation on twos-complement binary values, this instruction will cause a branch if there was an overflow. that is, branch if the twos-complement result was invalid. see bra instruction for further details of the execution of the branch. condition codes and boolean formulae: none affected source forms: bvs (rel) addressing modes, machine code, and cycle-by-cycle execution: the following table is a summary of all branch instructions. sxhinzvc cycle bvs (rel) addr data r/ w 1op29 1 2 op+1 rr 1 3 ffff 1 test boolean mnemonic opcode complementary branch comment r>m z+(n ? v)=0 bgt 2e r m ble 2f signed r 3 mn ? v=0 bge 2c rm bgt 2e signed rm c+z=0 bhi 22 r m bls 23 unsigned r 3 m c=0 bhs/bcc 24 rm bhi 22 unsigned r motorola instruction set details m68hc11 a-38 reference manual cba compare accumulators cba operation: (acca) C (accb) description: compares the contents of acca to the contents of accb and sets the con- dition codes, which may be used for arithmetic and logical conditional branches. both operands are unaffected. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v a7 ? b7 ? r7 + a7 ? b7 ? r7 set if a twos complement overflow resulted from the operation; cleared otherwise. c a7 ? b7 + b7 ? r7 + r7 ? a7 set if there was a borrow from the msb of the result; cleared otherwise. source forms: cba addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle cba (inh) addr data r/ w 1op11 1 2 op+1 1
m68hc11 instruction set details motorola reference manual a-39 clc clear carry clc operation: c bit 0 description: clears the c bit in the ccr. clc may be used to set up the c bit prior to a shift or rotate instruction involving the c bit. condition codes and boolean formulae: c0 cleared source forms: clc addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc 0 cycle clc (inh) addr data r/ w 1op0c1 2 op+1 1
motorola instruction set details m68hc11 a-40 reference manual cli clear interrupt mask cli operation: i bit 0 description: clears the interrupt mask bit in the ccr. when the i bit is clear, interrupts are enabled. there is one e-clock cycle delay in the clearing mechanism for the i bit so that, if interrupts were previously disabled, the next instruction after a cli will always be executed, even if there was an interrupt pending prior to execution of the cli instruction. condition codes and boolean formulae: i0 cleared source forms: cli addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc 0 cycle cli (inh) addr data r/ w 1op0e 1 2 op+1 1
m68hc11 instruction set details motorola reference manual a-41 clr clear clr operation: accx 0 or: m 0 description: the contents of accx or m are replaced with zeros. condition codes and boolean formulae: n0 cleared z1 set v0 cleared c0 cleared source forms: clra; clrb; clr (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc 0100 cycle clra (imm) clrb (dir) clr (ext) clr (ind,x) clr (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 4f 1 op 5f 1 op 7f 1 op 6f 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 6f 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll 00 0 x+ff 00 0 ffff 1 7 y+ff 00 0
motorola instruction set details m68hc11 a-42 reference manual clv clear twos complement overflow bit clv operation: v bit 0 description: clears the twos complement overflow bit in the ccr. condition codes and boolean formulae: v0 cleared source forms: clv addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc 0 cycle clv (inh) addr data r/ w 1op0a 1 2 op+1 1
m68hc11 instruction set details motorola reference manual a-43 cmp compare cmp operation: (acca) C (m) description: compares the contents of accx to the contents of m and sets the condition codes, which may be used for arithmetic and logical conditional branching. both operands are unaffected. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v x7 ? m7 ? r7 + x7 ? m7 ? r7 set if a twos complement overflow resulted from the operation; cleared otherwise. c x7 ? m7 + m7 ? r7 + r7 ? x7 set if there was a borrow from the msb of the result; cleared otherwise. source forms: cmpa (opr); cmpb (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle cmpa(imm) cmpa (dir) cmpa (ext) cmpa (ind,x) cmpa (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 81 1 op 91 1 op b1 1 op a1 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 a1 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1 cycle cmpb (imm) cmpb (dir) cmpb (ext) cmpb (ind,x) cmpb (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op c1 1 op d1 1 op f1 1 op e1 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 e1 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1
motorola instruction set details m68hc11 a-44 reference manual com complement com operation: accx ( accx) + $ff C (accx) or: m ( m) + $ff C (m) description: replaces the contents of accx or m with its ones complement. (each bit of the contents of accx or m is replaced with the complement of that bit.) to com- plement a value without affecting the c-bit, exclusive-or the value with $ff. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v0 cleared c1 set (for compatibility with m6800) source forms: coma; comb; com (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 1 cycle coma (inh) comb (inh) com (ext) com (ind,x) com (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 43 1 op 53 1 op 73 1 op 63 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 63 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll result 0 x+ff result 0 ffff 1 7 y+ff result 0
m68hc11 instruction set details motorola reference manual a-45 cpd compare double accumulator cpd operation: (accd) C (m : m + 1) description: compares the contents of accumulator d with a 16-bit value at the address specified and sets the condition codes accordingly. the compare is accomplished internally by doing a 16-bit subtract of ( m:m+1) from accumulator d without mod- ifying either accumulator d or (m : m + 1). condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. v d15 ? m15 ? r15 + d15 ? m15 ? r15 set if a twos complement overflow resulted from the operation; cleared otherwise. c d15 ? m15 + m15 ? r15 + r15 ? d15 set if the absolute value of the contents of memory is larger than the absolute value of the accumulator; cleared otherwise. source forms: cpd (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle cpd (imm) cpd (dir) cpd (ext) cpd (ind,x) cpd (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 1a 1 op 1a 1 op 1a 1 op 1a 1 op cd 1 2 op+1 83 1 op+1 93 1 op+1 b3 1 op+1 a3 1 op+1 a3 1 3 op+2 jj 1 op+2 dd 1 op+2 hh 1 op+2 ff 1 op+2 ff 1 4 op+3 kk 1 00dd (00dd) 1 op+3 ll 1 ffff 1 ffff 1 5 ffff 1 00dd+1 (00dd+1 ) 1 hhll (hhll) 1 x+ff (x+ff) 1 y+ff (y+ff) 1 6 ffff 1 hhll+1 (hhll+1) 1 x+ff+ 1 (x+ff+1 ) 1 y+ff+ 1 (y+ff+1 ) 1 7 ffff 1 ffff 1 ffff 1
motorola instruction set details m68hc11 a-46 reference manual cpx compare index register x cpx operation: (ix) C (m : m + 1) description: compares the contents of index register x with a 16-bit value at the address specified and sets the condition codes accordingly. the compare is accomplished internally by doing a 16-bit subtract of (m : m + 1) from index register x without modifying either index register x or (m : m + 1). condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. v ix15 ? m15 ? r15 + ix15 ? m15 ? r15 set if a twos complement overflow resulted from the operation; cleared otherwise. c ix15 ? m15 + m15 ? r15 + r15 ? ix15 set if the absolute value of the contents of memory is larger than the absolute value of the index register; cleared otherwise. source forms: cpx (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle cpx (imm) cpx (dir) cpx (ext) cpx (ind,x) cpx (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 8c 1 op 9c 1 op bc 1 op ac 1 op cd 1 2 op+1 jj 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ac 1 3 op+2 kk 1 00dd (00dd) 1 op+2 hh 1 ffff 1 op+2 ff 1 4 ffff 1 00dd+1 (00dd+1 ) 1 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 hhll+1 (hhll+1) 1 x+ff+ 1 (x+ff+1 ) 1 y+ff (y+ff) 1 6 ffff 1 ffff 1 y+ff+ 1 (y+ff+1 ) 1 7 ffff 1
m68hc11 instruction set details motorola reference manual a-47 cpy compare index register y cpy operation: (iy) C (m : m + 1) description: compares the contents of index register y with a 16-bit value at the address specified and sets the condition codes accordingly. the compare is accomplished internally by doing a 16-bit subtract of (m : m + 1) from index register y without modifying either index register y or (m : m + 1). condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. v iy15 ? m15 ? r15 + iy15 ? m15 ? r15 set if a twos complement overflow resulted from the operation; cleared otherwise. c iy15 ? m15 + m15 ? r15 + r15 ? iy15 set if the absolute value of the contents of memory is larger than the absolute value of the index register; cleared otherwise. source forms: cpy (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle cpy (imm) cpy (dir) cpy (ext) cpy (ind,x) cpy (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 18 1 op 18 1 op 18 1 op 1a 1 op 18 1 2 op+1 8c 1 op+1 9c 1 op+1 bc 1 op+1 ac 1 op+1 ac 1 3 op+2 jj 1 op+2 dd 1 op+2 hh 1 op+2 ff 1 op+2 ff 1 4 op+3 kk 1 00dd (00dd) 1 op+3 ll 1 ffff 1 ffff 1 5 ffff 1 00dd+1 (00dd+1 ) 1 hhll (hhll) 1 x+ff (x+ff) 1 y+ff (y+ff) 1 6 ffff 1 hhll+1 (hhll+1) 1 x+ff+ 1 (x+ff+1 ) 1 y+ff+ 1 (y+ff+1 ) 1 7 ffff 1 ffff 1 ffff 1
motorola instruction set details m68hc11 a-48 reference manual daa decimal adjust accumulator a daa operation: the following table summarizes the operation of the daa instruction for all le- gal combinations of input operands. a correction factor (column 5 in the following table) is added to acca to restore the result of an addition of two bcd operands to a valid bcd value and set or clear the carry bit. note columns (1) through (4) of the above table represent all possible cas- es which can result from any of the operations aba, add, or adc, with initial carry either set or clear, applied to two binary-coded-dec- imal operands. the table shows hexadecimal values. description: if the contents of acca and the state of the carry/borrow bit c and the state of the half-carry bit h are all the result of applying any of the operations aba, add, or adc to binary-coded-decimal operands, with or without an initial carry, the daa operation will adjust the contents of acca and the carry bit c in the ccr to repre- sent the correct binary-coded-decimal sum and the correct state of the c bit. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v? not defined c see table above state of c bit before daa (column 1) upper half-byte of acca (bits [7:4]) (column 2) initial half-carry h bit from ccr (column 3) lower half-byte of acca (bits [3:0]) (column 4) number added to acca by daa (column 5) state of c bit after daa (column 6) 0 0-9 0 0-9 00 0 0 0-8 0 a-f 06 0 0 0-9 1 0-3 06 0 0 a-f 0 0-9 60 1 0 9-f 0 a-f 66 1 0 a-f 1 0-3 66 1 1 0-2 0 0-9 60 1 1 0-2 0 a-f 66 1 1 0-3 1 0-3 66 1 sxhinzvc dd?d
m68hc11 instruction set details motorola reference manual a-49 daa decimal adjust accumulator a daa (continued) source forms: daa addressing modes, machine code, and cycle-by-cycle execution: for the purpose of illustration, consider the case where the bcd value $99 was just added to the bcd value $22. the add instruction is a binary operation, which yields the result $bb with no carry (c) or half carry (h). this corresponds to the fifth row of the table on the previous page. the daa instruction will therefore add the correction factor $66 to the result of the addition, giving a result of $21 with the carry bit set. this result corresponds to the bcd value $121, which is the expected bcd result. cycle daa (inh) addr data r/ w 1op19 1 2 op+1 1
motorola instruction set details m68hc11 a-50 reference manual dec decrement dec operation: accx (accx) C $01 or: m (m) C $01 description: subtract one from the contents of accx or m. the n, z, and v bits in the ccr are set or cleared according to the results of the operation. the c bit in the ccr is not affected by the operation, thus allowing the dec instruction to be used as a loop counter in multiple-precision computations. when operating on unsigned values, only beq and bne branches can be expect- ed to perform consistently. when operating on twos complement values, all signed branches are available. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v x7 ? x6 ? x5 ? x4 ? x3 ? x2 ? x1 ? x0 = r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if a twos complement overflow resulted from the operation; cleared otherwise. source forms: deca; decb; dec (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc ddd cycle deca (inh) decb (inh) dec (ext) dec (ind,x) dec (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 4a 1 op 5a 1 op 7a 1 op 6a 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 6a 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll result 0 x+ff result 0 ffff 1 7 y+ff result 1
m68hc11 instruction set details motorola reference manual a-51 des decrement stack pointer des operation: sp (sp) C $0001 description: subtract one from the stack pointer condition codes and boolean formulae: none affected source forms: des addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle des (inh) addr data r/ w 1op34 1 2 op+1 1 3sp 1
motorola instruction set details m68hc11 a-52 reference manual dex decrement index register x dex operation: ix (ix) C $0001 description: subtract one from index register x only the z bit is set or cleared according to the result of this operation. condition codes and boolean formulae: z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. source forms: dex addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d cycle dex (inh) addr data r/ w 1op09 1 2 op+1 1 3 ffff 1
m68hc11 instruction set details motorola reference manual a-53 dey decrement index register y dey operation: iy (iy) C $0001 description: subtract one from index register y only the z bit is set or cleared according to the result of this operation. condition codes and boolean formulae: z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. source forms: dey addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d cycle dey (inh) addr data r/ w 1op18 1 2 op+1 09 1 3 op+2 1 4 ffff 1
motorola instruction set details m68hc11 a-54 reference manual eor exclusive or eor operation: (accx) (accx) ? (m) description: performs the logical exclusive-or between the contents of accx and the contents of m and places the result in accx. (each bit of accx after the operation will be the logical exclusive-or of the corresponding bits of m and accx before the operation.) condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v0 cleared source forms: eora (opr); eorb (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle eora(imm) eora (dir) eora (ext) eora (ind,x) eora (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 88 1 op 98 1 op b8 1 op a8 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 a8 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1 cycle eorb (imm) eorb (dir) eorb (ext) eorb (ind,x) eorb (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op c8 1 op d8 1 op f8 1 op e8 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 e8 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1
m68hc11 instruction set details motorola reference manual a-55 fdiv fractional divide fdiv operation: (accd)/(ix); ix quotient, accd remainder description: performs an unsigned fractional divide of the 16-bit numerator in the d ac- cumulator by the 16-bit denominator in the index register x and sets the condition codes accordingly. the quotient is placed in the index register x, and the remain- der is placed in the d accumulator. the radix point is assumed to be in the same place for both the numerator and the denominator. the radix point is to the left of bit 15 for the quotient. the numerator is assumed to be less than the denominator. in the case of overflow (the denominator is less than or equal to the numerator) or divide by zero, the quotient is set to $ffff, and the remainder is indeterminate. fdiv is equivalent to multiplying the numerator by 216 and then performing a 32 by 16-bit integer divide. the result is interpreted as a binary-weighted fraction, which resulted from the division of a 16-bit integer by a larger 16-bit integer. a re- sult of $0001 corresponds to 0.000015, and $ffff corresponds to 0.99998. the remainder of an idiv instruction can be resolved into a binary-weighted fraction by an fdiv instruction. the remainder of an fdiv instruction can be resolved into the next 16-bits of binary-weighted fraction by another fdiv instruction. condition codes and boolean formulae: z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if quotient is $0000; cleared otherwise. v 1 if ix d set if denominator was less than or equal to the numerator; cleared otherwise. z ix15 ? ix14 ? ix13 ? ix12 ? ix11 ? ix10 ? ix9 ? ix8 ? ix7 ? ix6 ? ix5 ? ix4 ? ix3 ? ix2 ? ix1 ? ix0 set if denominator was $0000; cleared otherwise. source forms: fdiv addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc ddd cycle fdiv (inh) addr data r/ w 1op03 1 2 op+1 1 3-41 ffff 1
motorola instruction set details m68hc11 a-56 reference manual idiv integer divide idiv operation: (accd)/(ix); ix quotient, accd remainder description: performs an unsigned integer divide of the 16-bit numerator in d accumu- lator by the 16-bit denominator in index register x and sets the condition codes ac- cordingly. the quotient is placed in index register x, and the remainder is placed in the d accumulator. the radix point is assumed to be in the same place for both the numerator and the denominator. the radix point is to the right of bit zero for the quotient. in the case of divide by zero, the quotient is set to $ffff, and the remain- der is indeterminate. condition codes and boolean formulae: z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. v0 cleared c ix15 ? ix14 ? ix13 ? ix12 ? ix11 ? ix10 ? ix9 ? ix8 ? ix7 ? ix6 ? ix5 ? ix4 ? ix3 ? ix2 ? ix1 ? ix0 set if denominator was $0000; cleared otherwise. source forms: idiv addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d0d cycle idiv (inh) addr data r/ w 1op02 1 2 op+1 1 3-41 ffff 1
m68hc11 instruction set details motorola reference manual a-57 inc increment inc operation: accx (accx) + $01 or: m (m) + $01 description: add one to the contents of accx or m. the n, z, and v bits in the ccr are set or cleared according to the results of the operation. the c bit in the ccr is not affected by the operation, thus allowing the inc instruction to be used as a loop counter in multiple-precision computations. when operating on unsigned values, only beq and bne branches can be expect- ed to perform consistently. when operating on twos-complement values, all signed branches are available. condition codes and boolean formulae: nr7 set is msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v x7 ? x6 ? x5 ? x4 ? x3 ? x2 ? x1 ? x0 set if there is a twos complement overflow as a result of the operation; cleared oth- erwise. twos complement overflow occurs if and only if (accx) or (m) was $7f before the operation. source forms: inca; incb; inc (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc ddd? cycle inca (inh) incb (inh) inc (ext) inc (ind,x) inc (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 4c 1 op 5c 1 op 7c 1 op 6c 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 6c 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll result 0 x+ff result 0 ffff 1 7 y+ff result 1
motorola instruction set details m68hc11 a-58 reference manual ins increment stack pointer ins operation: sp (sp) + $0001 description: adds one to the stack pointer. condition codes and boolean formulae: none affected source forms: ins addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle ins (inh) addr data r/ w 1op31 1 2 op+1 1 3sp 1
m68hc11 instruction set details motorola reference manual a-59 inx increment index register x inx operation: ix (ix) + $0001 description: adds one to index register x. only the z bit is set or cleared according to the result of this operation. condition codes and boolean formulae: z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. source forms: inx addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d cycle inx (inh) addr data r/ w 1op08 1 2 op+1 1 3 ffff 1
motorola instruction set details m68hc11 a-60 reference manual iny increment index register y iny operation: iy (iy) + $0001 description: adds one to index register y. only the z bit is set or cleared according to the result of this operation. condition codes and boolean formulae: z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. source forms: iny addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d cycle iny (inh) addr data r/ w 1op18 1 2 op+1 08 1 3 op+2 1 4 ffff 1
m68hc11 instruction set details motorola reference manual a-61 jmp jump jmp operation: pc effective address description: a jump occurs to the instruction stored at the effective address. the effec- tive address is obtained according to the rules for extended or indexed address- ing. condition codes and boolean formulae: none affected source forms: jmp (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle jmp (ext) jmp (ind,x) jmp (ind,y) addr data r/w addr data r/w addr data r/w 1 op 7e 1 op 6e 1 op 18 1 2 op+1 hh 1 op+1 ff 1 op+1 6e 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 ffff 1
motorola instruction set details m68hc11 a-62 reference manual jsr jump to subroutine jsr operation: pc (pc) + $0003 (for extended or indexed, y addressing) or: pc (pc) + $0002 (for direct or indexed, x addressing) ? (pcl) push low-order return address onto stack sp (sp) C $0001 ? (pch) push high-order return address onto stack sp (sp) C $0001 pc effective addr load start address or requested subroutine description: the program counter is incremented by three or by two, depending on the addressing mode, and is then pushed onto the stack, eight bits at a time, least sig- nificant byte first. the stack pointer points to the next empty location in the stack. a jump occurs to the instruction stored at the effective address. the effective ad- dress is obtained according to the rules for extended, direct, or indexed ad- dressing. condition codes and boolean formulae: none affected source forms: jsr (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle jsr (dir) jsr (ext) jsr (ind,x) jsr (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w 1 op 9d 1 op bd 1 op ad 1 op 18 1 2 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ad 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 sp rtn lo 0 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 spC1 rtn hi 0 sp rtn lo 0 sp rtn lo 0 y+ff (y+ff) 1 6 spC1 rtn hi 0 spC1 rtn hi 0 sp rtn lo 0 7 spC1 rtn hi 0
m68hc11 instruction set details motorola reference manual a-63 lda load accumulator lda operation: accx (m) description: loads the contents of memory into the 8-bit accumulator. the condition codes are set according to the data. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v0 cleared source forms: ldaa (opr); ldab (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle ldaa (imm) ldaa (dir) ldaa (ext) ldaa (ind,x) ldaa (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 86 1 op 96 1 op b6 1 op a6 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 a6 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1 cycle ldab (imm) ldab (dir) ldab (ext) ldab (ind,x) ldab (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op c6 1 op d6 1 op f6 1 op e6 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 e6 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1
motorola instruction set details m68hc11 a-64 reference manual ldd load double accumulator ldd operation: accx (m : m + 1); acca (m), accb (m + 1) description: loads the contents of memory locations m an dm+1 into the double accu- mulator d. the condition codes are set according to the data. the information from location m is loaded into accumulator a, and the information from location m + 1 is loaded into accumulator b. condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. v0 cleared source forms: ldd (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle ldd (imm) ldd (dir) ldd (ext) ldd (ind,x) ldd (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op cc 1 op dc 1 op fc 1 op ec 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ec 1 3 op+2 kk 1 00dd (00dd) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 00dd+ 1 (00dd+1 ) 1 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 hhll+1 (hhll+1) 1 x+ff+ 1 (x+ff+1 ) 1 y+ff (y+ff) 1 6 y+ff+ 1 (y+ff+1 ) 1
m68hc11 instruction set details motorola reference manual a-65 lds load stack pointer lds operation: sph (m), spl (m + 1) description: loads the most significant byte of the stack pointer from the byte of memory at the address specified by the program, and loads the least significant byte of the stack pointer from the next byte of memory at one plus the address specified by the program. condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. v0 cleared source forms: lds (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle lds (imm) lds (dir) lds (ext) lds (ind,x) lds (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op be 1 op 9e 1 op ee 1 op ae 1 op 18 1 2 op+1 jj 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ae 1 3 op+2 kk 1 00dd (00dd) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 00dd+ 1 (00dd+1 ) 1 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 hhll+1 (hhll+1) 1 x+ff+ 1 (x+ff+1 ) 1 y+ff (y+ff) 1 6 y+ff+ 1 (y+ff+1 ) 1
motorola instruction set details m68hc11 a-66 reference manual ldx load index register x ldx operation: ixh (m), ixl (m + 1) description: loads the most significant byte of index register x from the byte of memory at the address specified by the program, and loads the least significant byte of in- dex register x from the next byte of memory at one plus the address specified by the program. condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. v0 cleared source forms: ldx (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle ldx (imm) ldx (dir) ldx (ext) ldx (ind,x) ldx (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op ce 1 op de 1 op fe 1 op ee 1 op cd 1 2 op+1 jj 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ee 1 3 op+2 kk 1 00dd (00dd) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 00dd+ 1 (00dd+1 ) 1 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 hhll+1 (hhll+1) 1 x+ff+ 1 (x+ff+1 ) 1 y+ff (y+ff) 1 6 y+ff+ 1 (y+ff+1 ) 1
m68hc11 instruction set details motorola reference manual a-67 ldy load index register y ldy operation: iyh (m), iyl (m + 1) description: loads the most significant byte of index register y from the byte of memory at the address specified by the program, and loads the least significant byte of in- dex register y from the next byte of memory at one plus the address specified by the program. condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. v0 cleared source forms: ldy (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle ldy (imm) ldy (dir) ldy (ext) ldy (ind,x) ldy (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 18 1 op 18 1 op 18 1 op 1a 1 op 18 1 2 op+1 ce 1 op+1 de 1 op+1 fe 1 op+1 ee 1 op+1 ee 1 3 op+2 jj 1 op+2 dd 1 op+2 hh 1 op+2 ff 1 op+2 ff 1 4 op+3 kk 1 00dd (00dd) 1 op+3 ll 1 ffff 1 ffff 1 5 00dd+ 1 (00dd+1 ) 1 hhll (hhll) 1 x+ff (x+ff) 1 y+ff (y+ff) 1 6 hhll+1 (hhll+1) 1 x+ff+ 1 (x+ff+1 ) 1 y+ff+ 1 (y+ff+1 ) 1
motorola instruction set details m68hc11 a-68 reference manual lsl logical shift left lsl (same as asl) operation: description: shifts all bits of the accx or m one place to the left. bit 0 is loaded with a zero. the c bit in the ccr is loaded from the most significant bit of accx or m. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. vn ? c = [n ? c] + [ n ? c] (for n and c after the shift) set if (n is set and c is clear) or (n is clear and c is set); cleared otherwise (for values of n and c after the shift). cm7 set if, before the shift, the msb of accx or m was set; cleared otherwise. source forms: lsla; lslb; lsl (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle lsla (inh) lslb (inh) lsl (ext) lsl (ind,x) lsl (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 48 1 op 58 1 op 78 1 op 68 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 68 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll result 0 x+ff result 0 ffff 1 7 y+ff result 0 c b7 C C C C C C b0 0
m68hc11 instruction set details motorola reference manual a-69 lsld logical shift left double lsld (same as asld) operation: description: shifts all bits of accd one place to the left. bit 0 is loaded with a zero. the c bit in the ccr is loaded from the most significant bit of accd. condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. vn ? c = [n ? c] + [ n ? c] (for n and c after the shift) set if (n is set and c is clear) or (n is clear and c is set); cleared otherwise (for values of n and c after the shift). c d15 set if, before the shift, the msb of accd was set; cleared otherwise. source forms: lsld (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle lsld (inh) addr data r/ w 1op05 1 2 op+1 1 3 ffff 1 c b7 C C C C C C b0 b7 C C C C C C b0 0 acca accb
motorola instruction set details m68hc11 a-70 reference manual lsr logical shift right lsr operation: description: shifts all bits of the accx or m one place to the right. bit 7 is loaded with zero. the c bit is loaded from the least significant bit of accx or m. condition codes and boolean formulae: n0 cleared. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. vn ? c = [n ? c] + [ n ? c] (for n and c after the shift) since n = 0, this simplifies to c (after the shift). cm0 set if, before the shift, the lsb of accx or m was set; cleared otherwise. source forms: lsra; lsrb; lsr (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc 0ddd cycle lsra (inh) lsrb (inh) lsr (ext) lsr (ind,x) lsr (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 44 1 op 54 1 op 74 1 op 64 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 64 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll result 0 x+ff result 0 ffff 1 7 y+ff result 0 c b7 C C C C C C b0 0
m68hc11 instruction set details motorola reference manual a-71 lsrd logical shift right double accumulator lsrd operation: description: shifts all bits of accd one place to the right. bit 15 (msb of acca) is load- ed with zero. the c bit is loaded from the least significant bit of accd (lsb of ac- cb). condition codes and boolean formulae: n0 cleared. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. vd0 set if, after the shift operation, c is set; cleared otherwise. cd0 set if, before the shift, the least significant bit of accd was set; cleared otherwise. source forms: lsrd (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc 0ddd cycle lsrd (inh) addr data r/ w 1op04 1 2 op+1 1 3 ffff 1 c b7 C C C C C C b0 b7 C C C C C C b0 acca accb 0
motorola instruction set details m68hc11 a-72 reference manual mul multiply unsigned mul operation: accd (acca) (accb) description: multiplies the 8-bit unsigned binary value in accumulator a by the 8-bit un- signed binary value in accumulator b to obtain a 16-bit unsigned result in the dou- ble accumulator d. unsigned multiply allows multiple-precision operations. the carry flag allows rounding the most significant byte of the result through the se- quence: mul, adca #0. condition codes and boolean formulae: cr7 set if bit 7 of the result (accb bit 7) is set; cleared otherwise. source forms: mul addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d cycle mul (inh) addr data r/ w 1op3d1 2 op+1 1 3C10 ffff 1
m68hc11 instruction set details motorola reference manual a-73 neg negate neg operation: accx C (accx) = $00 C (accx) or: m C (m) = $00 C (m) description: replaces the contents of accx or m with its twos complement; the value $80 is left unchanged condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if there is a twos complement overflow from the implied subtraction from zero; cleared otherwise. a twos complement overflow will occur if and only if the con- tents of accx or m is $80. c r7 + r6 + r5 + r4 + r3 + r2 + r1 + r0 set if there is a borrow in the implied subtraction from zero; cleared otherwise. the c bit will be set in all cases except when the contents of accx or m is $00. source forms: nega; negb; neg (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle nega (inh) negb (inh) neg (ext) neg (ind,x) neg (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 40 1 op 50 1 op 70 1 op 60 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 60 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll result 0 x+ff result 0 ffff 1 7 y+ff result 0
motorola instruction set details m68hc11 a-74 reference manual nop no operation nop description: this is a single-byte instruction that causes only the program counter to be incremented. no other registers are affected. this instruction is typically used to produce a time delay although some software disciplines discourage cpu frequen- cy-based time delays. during debug, nop instructions are sometimes used to tem- porarily replace other machine code instructions, thus disabling the replaced instructions. condition codes and boolean formulae: none affected source forms: nop addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle nop (inh) addr data r/ w 1op01 1 2 op+1 1
m68hc11 instruction set details motorola reference manual a-75 ora inclusive or ora operation: (accx) (accx) + (m) description: performs the logical inclusive-or between the contents of accx and the contents of m and places the result in accx. (each bit of accx after the operation will be the logical inclusive-or of the corresponding bits of m and accx before the operation.) condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v0 cleared source forms: oraa (opr); orab (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle oraa (imm) oraa (dir) oraa (ext) oraa (ind,x) oraa (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 8a 1 op 9a 1 op ba 1 op aa 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 aa 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1 cycle orab (imm) orab (dir) orab (ext) orab (ind,x) orab (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op ca 1 op da 1 op fa 1 op ea 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ea 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1
motorola instruction set details m68hc11 a-76 reference manual psh push data onto stack psh operation: ? accx, sp (sp) C $0001 description: the contents of accx are stored on the stack at the address contained in the stack pointer. the stack pointer is then decremented. push instructions are commonly used to save the contents of one or more cpu registers at the start of a subroutine. just before returning from the subroutine, cor- responding pull instructions are used to restore the saved cpu registers so the subroutine will appear not to have affected these registers. condition codes and boolean formulae: none affected source forms: psha; pshb; addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle psha (inh) pshb (inh) addr data r/w addr data r/w 1 op 36 1 op 37 1 2 op+1 1 op+1 1 3 sp (a) 0 sp (b) 0
m68hc11 instruction set details motorola reference manual a-77 pshx push index register x onto stack pshx operation: ? (ixl), sp (sp) C $0001 ? (ixh), sp (sp) C $0001 description: the contents of index register x are pushed onto the stack (low-order byte first) at the address contained in the stack pointer. the stack pointer is then decre- mented by two. push instructions are commonly used to save the contents of one or more cpu registers at the start of a subroutine. just before returning from the subroutine, cor- responding pull instructions are used to restore the saved cpu registers so the subroutine will appear not to have affected these registers. condition codes and boolean formulae: none affected source forms: pshx addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle pshx (inh) addr data r/ w 1op3c1 2 op+1 1 3 sp (ixl) 0 4 spC1 (ixh) 0
motorola instruction set details m68hc11 a-78 reference manual pshy push index register y onto stack pshy operation: ? (iyl), sp (sp) C $0001 ? (iyh), sp (sp) C $0001 description: the contents of index register y are pushed onto the stack (low-order byte first) at the address contained in the stack pointer. the stack pointer is then decre- mented by two. push instructions are commonly used to save the contents of one or more cpu registers at the start of a subroutine. just before returning from the subroutine, cor- responding pull instructions are used to restore the saved cpu registers so the subroutine will appear not to have affected these registers. condition codes and boolean formulae: none affected source forms: pshy addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle pshy (inh) addr data r/ w 1op18 1 2 op+1 3c 1 3 op+2 1 4 sp (iyl) 0 5 spC1 (iyh) 0
m68hc11 instruction set details motorola reference manual a-79 pul pull data from stack pul operation: sp (sp) + $0001, y accx description: the stack pointer is incremented. the accx is then loaded from the stack at the address contained in the stack pointer. push instructions are commonly used to save the contents of one or more cpu registers at the start of a subroutine. just before returning from the subroutine, cor- responding pull instructions are used to restore the saved cpu registers so the subroutine will appear not to have affected these registers. condition codes and boolean formulae: none affected source forms: pula; pulb; addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle pula (inh) pulb (inh) addr data r/w addr data r/w 1 op 32 1 op 33 1 2 op+1 1 op+1 1 3sp 1 sp 1 4 sp+1 get a 1 sp+1 get b 1
motorola instruction set details m68hc11 a-80 reference manual pulx pull index register x from stack pulx operation: sp (sp) + $0001; y (ixh) sp (sp) + $0001; y (ixl) description: index register x is pulled from the stack (high-order byte first) beginning at the address contained in the stack pointer plus one. the stack pointer is increment- ed by two in total. push instructions are commonly used to save the contents of one or more cpu registers at the start of a subroutine. just before returning from the subroutine, cor- responding pull instructions are used to restore the saved cpu registers so the subroutine will appear not to have affected these registers. condition codes and boolean formulae: none affected source forms: pulx addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle pulx (inh) addr data r/ w 1op38 1 2 op+1 1 3sp 1 4 sp+1 get ixh 1 5 sp+2 get ixl 1
m68hc11 instruction set details motorola reference manual a-81 puly pull index register y from stack puly operation: sp (sp) + $0001; y (iyh) sp (sp) + $0001; y (iyl) description: index register y is pulled from the stack (high-order byte first) beginning at the address contained in the stack pointer plus one. the stack pointer is increment- ed by two in total. push instructions are commonly used to save the contents of one or more cpu registers at the start of a subroutine. just before returning from the subroutine, cor- responding pull instructions are used to restore the saved cpu registers so the subroutine will appear not to have affected these registers. condition codes and boolean formulae: none affected source forms: puly addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle puly (inh) addr data r/ w 1op18 1 2 op+1 38 1 3 op+2 1 4sp 1 5 sp+1 get iyh 1 6 sp+2 get iyl 1
motorola instruction set details m68hc11 a-82 reference manual rol rotate left rol operation: description: shifts all bits of the accx or m one place to the left. bit 0 is loaded from the c bit. the c bit in the ccr is loaded from the most significant bit of accx or m. the rotate operations include the carry bit to allow extension of the shift and rotate operations to multiple bytes. for example, to shift a 24-bit value left one bit, the se- quence asl low, rol mid, rol high could be used where low, mid, and high refer to the low-order, middle, and high-order bytes of the 24-bit value, re- spectively. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. vn ? c = [n ? c] + [ n ? c] (for n and c after the rotate) set if (n is set and c is clear) or (n is clear and c is set); cleared otherwise (for values of n and c after the rotate). cm7 set if, before the rotate, the msb of accx or m was set; cleared otherwise. source forms: rola; rolb; rol (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle rola (inh) rolb (inh) rol (ext) rol (ind,x) rol (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 49 1 op 59 1 op 79 1 op 69 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 69 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll result 0 x+ff result 0 ffff 1 7 y+ff result 0
m68hc11 instruction set details motorola reference manual a-83 ror rotate right ror operation: description: shifts all bits of the accx or m one place to the right. bit 7 is loaded from the c bit. the c bit in the ccr is loaded from the least significant bit of accx or m. the rotate operations include the carry bit to allow extension of the shift and ro- tate operations to multiple bytes. for example, to shift a 24-bit value right one bit, the sequence lsr high, ror mid, ror low could be used where low, mid, and high refer to the low-order, middle, and high-order bytes of the 24-bit value, respectively. the first lsr could be replaced by asr to maintain the original value of the sign bit (msb of high-order byte) of the 24-bit value. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. vn ? c = [n ? c] + [ n ? c] (for n and c after the rotate) set if (n is set and c is clear) or (n is clear and c is set); cleared otherwise (for values of n and c after the rotate). cm0 set if, before the rotate, the lsb of accx or m was set; cleared otherwise. source forms: rora; rorb; ror (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle rora (inh) rorb (inh) ror (ext) ror (ind,x) ror (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 46 1 op 56 1 op 76 1 op 66 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 66 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 hhll result 0 x+ff result 0 ffff 1 7 y+ff result 0
motorola instruction set details m68hc11 a-84 reference manual rti return from interrupt rti operation: sp (sp)+ $0001, y (ccr) sp (sp)+ $0001, y (accb) sp (sp)+ $0001, y (acca) sp (sp)+ $0001, y (ixh) sp (sp)+ $0001, y (ixl) sp (sp)+ $0001, y (iyh) sp (sp)+ $0001, y (iyl) sp (sp)+ $0001, y (pch) sp (sp)+ $0001, y (pcl) description: the condition code, accumulators b and a, index registers x and y, and the program counter will be restored to a state pulled from the stack. the x bit in the ccr may be cleared as a result of an rti instruction but may not be set if it was cleared prior to execution of the rti instruction. condition codes and boolean formulae: condition code bits take on the value of the corresponding bit of the unstacked ccr except that the x bit may not change from a zero to a one. software can leave x set, leave x clear, or change x from one to zero. the xirq interrupt mask can only become set as a result of a reset or recognition of an xirq interrupt. source forms: rti addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d?dddddd cycle rti (inh) addr data r/ w 1op3b 1 2 op+1 1 3sp 1 4 sp+1 get cc 1 5 sp+2 get b 1 6 sp+3 get a 1 7 sp+4 get ixh 1 8 sp+5 get ixl 1 9 sp+6 get iyh 1 10 sp+7 get iyl 1 11 sp+8 rtn hi 1 12 sp+9 rtn lo 1
m68hc11 instruction set details motorola reference manual a-85 rts return from subroutine rts operation: sp (sp)+ $0001, y (pch) sp (sp)+ $0001, y (pcl) description: the stack pointer is incremented by one. the contents of the byte of mem- ory, at the address now contained in the stack pointer, are loaded into the high-or- der eight bits of the program counter. the stack pointer is again incremented by one. the contents of the byte of memory, at the address now contained in the stack pointer, are loaded into the low-order eight bits of the program counter. condition codes and boolean formulae: none affected source forms: rts addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle rts (inh) addr data r/ w 1op39 1 2 op+1 1 3sp 1 4 sp+1 rtn hi 1 5 sp+2 rtn lo 1
motorola instruction set details m68hc11 a-86 reference manual sba subtract accumulators sba operation: acca (acca) C (accb) description: subtracts the contents of accb from the contents of acca and places the result in acca. the contents of accb are not affected. for subtract instructions, the c bit in the ccr represents a borrow. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v a7 ? b7 ? r7 + a7 ? b7 ? r7 set if a twos complement overflow resulted from the operation; cleared otherwise. c a7 ? b7 + b7 ? r7 + r7 ? a7 set if the absolute value of accb is larger than the absolute value of acca; cleared otherwise. source forms: sba addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle sba (inh) addr data r/ w 1op10 1 2 op+1 1
m68hc11 instruction set details motorola reference manual a-87 sbc subtract with carry sbc operation: accx (acca) C (m) C (c) description: subtracts the contents of m and the contents of c from the contents of accx and places the result in accx. for subtract instructions the c bit in the ccr represents a borrow. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v x7 ? m7 ? r7 + x7 ? m7 ? r7 set if a twos complement overflow resulted from the operation; cleared otherwise. c x7 ? m7 + m7 ? r7 + r7 ? x7 set if the absolute value of the contents of memory plus previous carry is larger than the absolute value of the accumulator; cleared otherwise. source forms: sbca (opr); sbcb (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle sbca (imm) sbca (dir) sbca (ext) sbca (ind,x) sbca (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 82 1 op 92 1 op b2 1 op a2 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 a2 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1 cycle sbcb (imm) sbcb (dir) sbcb (ext) sbcb (ind,x) sbcb (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op c2 1 op d2 1 op f2 1 op e2 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 e2 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1
motorola instruction set details m68hc11 a-88 reference manual sec set carry sec operation: c bit 1 description: sets the c bit in the ccr. condition codes and boolean formulae: c1 set source forms: sec addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc 1 cycle sec (inh) addr data r/ w 1op0d1 2 op+1 1
m68hc11 instruction set details motorola reference manual a-89 sei set interrupt mask sei operation: i bit 1 description: sets the interrupt mask bit in the ccr. when the i bet is set, all maskable interrupts are inhibited, and the mpu will recognize only non-maskable interrupt sources or an swi. condition codes and boolean formulae: i1 set source forms: sei addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc 1 cycle sei (inh) addr data r/ w 1op0f 1 2 op+1 1
motorola instruction set details m68hc11 a-90 reference manual sev set twos complement overflow bit sev operation: v bit 1 description: sets the interrupt mask bit in the ccr. when the i bet is set, all maskable interrupts are inhibited, and the mpu will recognize only non-maskable interrupt sources or an swi. condition codes and boolean formulae: v1 set source forms: sev addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc 1 cycle sev (inh) addr data r/ w 1op0b 1 2 op+1 1
m68hc11 instruction set details motorola reference manual a-91 sta store accumulator sta operation: (m) (accx) description: stores the contents of accx in memory. the contents of accx remains the same. condition codes and boolean formulae: nx7 set if msb of result is set; cleared otherwise. z x7 ? x6 ? x5 ? x4 ? x3 ? x2 ? x1 ? x0 set if result is $00; cleared otherwise. v0 cleared source forms: staa (opr); stab (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle staa (dir) staa (ext) staa (ind,x) staa (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w 1 op 97 1 op b7 1 op a7 1 op 18 1 2 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 a7 1 3 00dd (a) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (a) 1 x+ff (a) 1 ffff 1 5 y+ff (a) 0 cycle stab (dir) stab (ext) stab (ind,x) stab (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w 1 op d7 1 op f7 1 op e7 1 op 18 1 2 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 e7 1 3 00dd (b) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (b) 1 x+ff (b) 1 ffff 1 5 y+ff (b) 0
motorola instruction set details m68hc11 a-92 reference manual std store double accumulator std operation: m : m + 1 (accd); m (acca), m + 1 (accb) description: stores the contents of double accumulator accd in memory. the contents of accd remain unchanged. condition codes and boolean formulae: n d15 set if msb of result is set; cleared otherwise. z d15 ? d14 ? d13 ? d12 ? d11 ? d10 ? d9 ? d8 ? d7 ? d6 ? d5 ? d4 ? d3 ? d2 ? d1 ? d0 set if result is $0000; cleared otherwise. v0 cleared source forms: std (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle std (dir) std (ext) std (ind,x) std (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w 1 op dd 1 op fd 1 op ed 1 op 18 1 2 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ed 1 3 00dd (a) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 00dd+ 1 (b) 1 hhll (a) 1 x+ff (a) 1 ffff 1 5 hhll+1 (b) 1 x+ff+ 1 (b) 1 y+ff (a) 1 6 y+ff+ 1 (b) 1
m68hc11 instruction set details motorola reference manual a-93 stop stop processing stop description: if the s bit in the ccr is set, then the stop instruction is disabled and op- erates like the nop instruction. if the s bit in the ccr is clear, the stop instruction causes all system clocks to halt, and the system is placed in a minimum-power standby mode. all cpu registers remain unchanged. i/o pins also remain unaffect- ed. recovery from stop may be accomplished by reset, xirq, or an unmasked irq. when recovering from stop with xirq, if the x bit in the ccr is clear, exe- cution will resume with the stacking operations for the xirq interrupt. if the x bit in the ccr is set, masking xirq interrupts, execution will resume with the opcode fetch for the instruction which follows the stop instruction (continue). an error in some mask sets of the m68hc11 caused incorrect recover from stop under very specific unusual conditions. if the opcode of the instruction before the stop instruction came from column 4 or 5 of the opcode map, the stop instruc- tion was incorrectly interpreted as a two-byte instruction. a simple way to avoid this potential problem is to put a nop instruction (which is a column 0 opcode) imme- diately before any stop instruction. condition codes and boolean formulae: none affected source forms: stop addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle stop (inh) addr data r/ w 1opcf1 2 op+1 1
motorola instruction set details m68hc11 a-94 reference manual sts store stack pointer st operation: m (sph), m + 1 (spl) description: stores the most significant byte of the stack pointer in memory at the ad- dress specified by the program and stores the least significant byte of the stack pointer at the next location in memory, at one plus the address specified by the pro- gram. condition codes and boolean formulae: n sp15 set if msb of result is set; cleared otherwise. z sp15 ? sp14 ? sp13 ? sp12 ? sp11 ? sp10 ? sp9 ? sp8 ? sp7 ? sp6 ? sp5 ? sp4 ? sp3 ? sp2 ? sp1 ? sp0 set if result is $0000; cleared otherwise. v0 cleared source forms: sts (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle sts (dir) sts (ext) sts (ind,x) sts (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w 1 op 9f 1 op bf 1 op af 1 op 18 1 2 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 af 1 3 00dd (sph) 0 op+2 ll 1 ffff 1 op+2 ff 1 4 00dd+ 1 (spl) 0 hhll (sph) 0 x+ff (sph) 0 ffff 1 5 hhll+1 (spl) 0 x+ff+ 1 (spl) 0 y+ff (sph) 0 6 y+ff+ 1 (spl) 0
m68hc11 instruction set details motorola reference manual a-95 stx store index register x stx operation: m (ixh), m + 1 (ixl) description: stores the most significant byte of index register x in memory at the address specified by the program, and stores the least significant byte of index register x at the next location in memory, at one plus the address specified by the program. condition codes and boolean formulae: n ix15 set if msb of result is set; cleared otherwise. z ix15 ? ix14 ? ix13 ? ix12 ? ix11 ? ix10 ? ix9 ? ix8 ? ix7 ? ix6 ? ix5 ? ix4 ? ix3 ? ix2 ? ix1 ? ix0 set if result is $0000; cleared otherwise. v0 cleared source forms: stx (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle stx (dir) stx (ext) stx (ind,x) stx (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w 1 op df 1 op ff 1 op ef 1 op cd 1 2 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ef 1 3 00dd (ixh) 0 op+2 ll 1 ffff 1 op+2 ff 1 4 00dd+ 1 (ixl) 0 hhll (ixh) 0 x+ff (ixh) 0 ffff 1 5 hhll+1 (ixl) 0 x+ff+ 1 (ixl) 0 y+ff (ixh) 0 6 y+ff+ 1 (ixl) 0
motorola instruction set details m68hc11 a-96 reference manual sty store index register y sty operation: m (iyh), m + 1 (iyl) description: stores the most significant byte of index register y in memory at the address specified by the program, and stores the least significant byte of index register y at the next location in memory, at one plus the address specified by the program. condition codes and boolean formulae: n iy15 set if msb of result is set; cleared otherwise. z iy15 ? iy14 ? iy13 ? iy12 ? iy11 ? iy10 ? iy9 ? iy8 ? iy7 ? iy6 ? iy5 ? iy4 ? iy3 ? iy2 ? iy1 ? iy0 set if result is $0000; cleared otherwise. v0 cleared source forms: sty (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle sty (dir) sty (ext) sty (ind,x) sty (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w 1 op df 1 op ff 1 op ef 1 op cd 1 2 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 ef 1 3 00dd (iyh) 0 op+2 ll 1 ffff 1 op+2 ff 1 4 00dd+ 1 (iyl) 0 hhll (iyh) 0 x+ff (iyh) 0 ffff 1 5 hhll+1 (iyl) 0 x+ff+ 1 (iyl) 0 y+ff (iyh) 0 6 y+ff+ 1 (iyl) 0
m68hc11 instruction set details motorola reference manual a-97 sub subtract sub operation: accx (accx) C (m) description: subtracts the contents of m from the contents of accx and places the result in accx. for subtract instructions, the c bit in the ccr represents a borrow. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v x7 ? m7 ? r7 + x7 ? m7 ? r7 set if a twos complement overflow resulted from the operation; cleared otherwise. c x7 ? m7 + m7 ? r7 + r7 ? x7 set if the absolute value of the contents of memory plus previous carry is larger than the absolute value of the accumulator; cleared otherwise. source forms: suba (opr); subb (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle suba (imm) suba (dir) suba (ext) suba (ind,x) suba (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 80 1 op 90 1 op b0 1 op a0 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 a0 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1 cycle subb (imm) subb (dir) subb (ext) subb (ind,x) subb (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op c0 1 op d0 1 op f0 1 op e0 1 op 18 1 2 op+1 ii 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 e0 1 3 00dd (00dd ) 1 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 y+ff (y+ff) 1
motorola instruction set details m68hc11 a-98 reference manual subd subtract double accumulator subd operation: accd (accd) C (m : m + 1) description: subtracts the contents o fm:m+1 from the contents of double accumulator d and places the result in accd. for subtract instructions, the c bit in the ccr represents a borrow. condition codes and boolean formulae: n r15 set if msb of result is set; cleared otherwise. z r15 ? r14 ? r13 ? r12 ? r11 ? r10 ? r9 ? r8 ? r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $0000; cleared otherwise. v d15 ? m15 ? r15 + d15 ? m15 ? r15 set if a twos complement overflow resulted from the operation; cleared otherwise. c d15 ? m15 + m15 ? r15 + r15 ? d15 set if the absolute value of the contents of memory is larger than the absolute value of the accumulator; cleared otherwise. source forms: subd (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dddd cycle subd (imm) subd (dir) subd (ext) subd (ind,x) subd (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 83 1 op 93 1 op b3 1 op a3 1 op 18 1 2 op+1 jj 1 op+1 dd 1 op+1 hh 1 op+1 ff 1 op+1 a3 1 3 op+2 kk 1 00dd (00dd) 1 op+2 hh 1 ffff 1 op+2 ff 1 4 ffff 1 00dd+1 (00dd+1 ) 1 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 hhll+1 (hhll+1) 1 x+ff+ 1 (x+ff+1 ) 1 y+ff (y+ff) 1 6 ffff 1 ffff 1 y+ff+ 1 (y+ff+1 ) 1 7 ffff 1
m68hc11 instruction set details motorola reference manual a-99 swi software interrupt swi operation: pc (pc)+ $0001 ? (pcl), sp (sp) C $0001 ? (pch), sp (sp) C $0001 ? (iyl), sp (sp) C $0001 ? (iyh), sp (sp) C $0001 ? (ixl), sp (sp) C $0001 ? (ixh), sp (sp) C $0001 ? (acca), sp (sp) C $0001 ? (accb), sp (sp) C $0001 ? (ccr), sp (sp) C $0001 i 1, pc (swi vector) description: the program counter is incremented by one. the program counter, index registers y and x, and accumulators a and b are pushed onto the stack. the ccr is then pushed onto the stack. the stack pointer is decremented by one after each byte of data is stored on the stack. the i bit in the ccr is then set. the program counter is loaded with the address stored at the swi vector, and instruction execu- tion resumes at this location. this instruction is not maskable by the i bit. condition codes and boolean formulae: i1 set source forms: swi addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc 1 cycle swi (inh) addr data r/ w 1op3f 1 2 op+1 1 3 sp rtn lo 0 4 spC1 rtn hi 0 5 spC2 (iyl) 0 6 spC3 (iyh) 0 7 spC4 (ixl) 0 8 spC5 (ixh) 0 9 spC6 (a) 0 10 spC7 (b) 0 11 spC8 (ccr) 0 12 spC8 (ccr) 1 13 vec hi svc hi 1 14 vec lo svc lo 1
motorola instruction set details m68hc11 a-100 reference manual tab transfer from accumulator a to b tab operation: accb (acca) description: moves the contents of acca to accb. the former contents of accb are lost; the contents of acca are not affected. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v0 cleared. source forms: tab addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle tab (inh) addr data r/ w 1op16 1 2 op+1 1
m68hc11 instruction set details motorola reference manual a-101 tap transfer from accumulator a to ccr tap operation: ccr (acca) description: transfers the contents of bit positions 7C0 of accumulator a to the corre- sponding bit positions of the ccr. the contents of accumulator a remain un- changed. the x bit in the ccr may be cleared as a result of a tap instruction but may not be set if it was clear prior to execution of the tap instruction. condition codes and boolean formulae: condition code bits take on the value of the corresponding bit of accumulator a except that the x bit may not change from a zero to a one. software can leave x set, leave x clear, or change x from one to zero. the xirq interrupt mask can only become set as a result of a reset or recognition of an xirq interrupt. source forms: tap addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc d?dddddd cycle tap (inh) addr data r/ w 1op06 1 2 op+1 1 7 6 5432 1 0 acca ccr carry/borrow over?ow (twos complement) zero negative i interrupt mask half carry x interrupt mask stop disable bit positions sx hi nzvc
motorola instruction set details m68hc11 a-102 reference manual tba transfer from accumulator b to a tba operation: acca (accb) description: moves the contents of accb to acca. the former contents of acca are lost; the contents of accb are not affected. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z r7 ? r6 ? r5 ? r4 ? r3 ? r2 ? r1 ? r0 set if result is $00; cleared otherwise. v0 cleared. source forms: tba addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 cycle tba (inh) addr data r/ w 1op17 1 2 op+1 1
m68hc11 instruction set details motorola reference manual a-103 test test operation (test mode only) test description: this is a single-byte instruction that causes the program counter to be con- tinuously incremented. it can only be executed while in the test mode. the mpu must be reset to exit this instruction. code execution is suspended during this in- struction. this is an illegal opcode when not in test mode. condition codes and boolean formulae: none affected source forms: test addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle test (inh) addr data r/ w 1op00 1 2 op+1 1 3 op+2 1 4 op+3 1 5Cn prevC1 (prevC1) 1
motorola instruction set details m68hc11 a-104 reference manual tpa transfer from ccr to accumulator a tpa operation: (acca) (ccr) description: transfers the contents of the ccr to corresponding bit positions of accu- mulator a. the ccr remains unchanged. condition codes and boolean formulae: none affected source forms: tpa addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle tpa (inh) addr data r/ w 1op07 1 2 op+1 1 7 6 5432 1 0 acca ccr carry/borrow over?ow (twos complement) zero negative i interrupt mask half carry x interrupt mask stop disable bit positions sx hi nzvc
m68hc11 instruction set details motorola reference manual a-105 tst test tst operation: (accx) C $00 or: (m) C $00 description: subtracts $00 from the contents of accx or m and sets the condition codes accordingly. the subtraction is accomplished internally without modifying either accx or m. the tst instruction provides only minimum information when testing unsigned val- ues. since no unsigned value is less than zero, blo and blx have no utility. while bhi could be used after tst, it provides exactly the same control as bne, which is preferred. after testing signed values, all signed branches are available. condition codes and boolean formulae: nr7 set if msb of result is set; cleared otherwise. z m7 ? m6 ? m5 ? m4 ? m3 ? m2 ? m1 ? m0 set if result is $00; cleared otherwise. v0 cleared c0 cleared source forms: tsta; tstb; tst (opr) addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc dd0 0 cycle tsta (inh) tstb (inh) tst (ext) tst (ind,x) tst (ind,y) addr data r/w addr data r/w addr data r/w addr data r/w addr data r/w 1 op 4d 1 op 5d 1 op 7d 1 op 6d 1 op 18 1 2 op+1 1 op+1 1 op+1 hh 1 op+1 ff 1 op+1 6d 1 3 op+2 ll 1 ffff 1 op+2 ff 1 4 hhll (hhll) 1 x+ff (x+ff) 1 ffff 1 5 ffff 1 ffff 1 y+ff (y+ff) 1 6 ffff 1 ffff 1 ffff 1 7 ffff 1
motorola instruction set details m68hc11 a-106 reference manual tsx transfer from sp to index register x tsx operation: ix (sp) + $0001 description: loads the index register x with one plus the contents of the stack pointer. the contents of the stack pointer remain unchanged. after a tsx instruction the index register x points at the last value that was stored on the stack. condition codes and boolean formulae: none affected source forms: tsx addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle tsx (inh) addr data r/ w 1op30 1 2 op+1 1 3sp 1
m68hc11 instruction set details motorola reference manual a-107 tsy transfer from sp to index register y tsy operation: iy (sp) + $0001 description: loads the index register y with one plus the contents of the stack pointer. the contents of the stack pointer remain unchanged. after a tsy instruction the index register y points at the last value that was stored on the stack. condition codes and boolean formulae: none affected source forms: tsy addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle tsy (inh) addr data r/ w 1op18 1 2 op+1 30 1 3 op+2 1 4sp 1
motorola instruction set details m68hc11 a-108 reference manual txs transfer from index register x to sp txs operation: sp (ix) C $0001 description: loads the stack pointer with the contents of index register x minus one. the contents of index register x remain unchanged. condition codes and boolean formulae: none affected source forms: txs addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle txs (inh) addr data r/ w 1op35 1 2 op+1 1 3 ffff 1
m68hc11 instruction set details motorola reference manual a-109 tys transfer from index register y to sp tys operation: sp (iy) C $0001 description: loads the stack pointer with the contents of index register y minus one. the contents of index register y remain unchanged. condition codes and boolean formulae: none affected source forms: tys addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle tys (inh) addr data r/ w 1op18 1 2 op+1 35 1 3 op+2 1 4 ffff 1
motorola instruction set details m68hc11 a-110 reference manual wai wait for interrupt wai operation: pc (pc)+ $0001 ? (pcl), sp (sp) C $0001 ? (pch), sp (sp) C $0001 ? (iyl), sp (sp) C $0001 ? (iyh), sp (sp) C $0001 ? (ixl), sp (sp) C $0001 ? (ixh), sp (sp) C $0001 ? (acca), sp (sp) C $0001 ? (accb), sp (sp) C $0001 ? (ccr), sp (sp) C $0001 description: the program counter is incremented by one. the program counter, index registers y and x, and accumulators a and b are pushed onto the stack. the ccr is then pushed onto the stack. the stack pointer is decremented by one after each byte of data is stored on the stack. the mpu then enters a wait state for an integer number of mpu e-clock cycles. while in the wait state, the address/data bus repeatedly runs read bus cycles to the address where the ccr contents were stacked. the mpu leaves the wait state when it senses any interrupt that has not been masked. upon leaving the wait state, the mpu sets the i bit in the ccr, fetches the vector (address) corresponding to the interrupt sensed, and instruction execution is re- sumed at this location. condition codes and boolean formulae: although the wai instruction itself does not alter the condition code bits, the inter- rupt which causes the mcu to resume processing causes the i bit (and the x bit if the interrupt was xirq) to be set as the interrupt vector is being fetched. sxhinzvc 1
m68hc11 instruction set details motorola reference manual a-111 wai wait for interrupt (continued) wai source forms: wai addressing modes, machine code, and cycle-by-cycle execution: cycle wai (inh) addr data r/ w 1op3e 1 2 op+1 1 3 sp rtn lo 0 4 spC1 rtn hi 0 5 spC2 (iyl) 0 6 spC3 (iyh) 0 7 spC4 (ixl) 0 8 spC5 (ixh) 0 9 spC6 (a) 0 10 spC7 (b) 0 11 spC8 (ccr) 0 12 spC8 (ccr) 1 13 vec hi svc hi 1 14 vec lo svc lo 1
motorola instruction set details m68hc11 a-112 reference manual xgdx exchange double accumulator and xgdx index register x operation: (ix) t (accd) description: exchanges the contents of double accumulator accd and the contents of index register x. a common use for xgdx is to move an index value into the dou- ble accumulator to allow 16-bit arithmetic calculations on the index value before ex- changed the updated index value back into the x index register. condition codes and boolean formulae: none affected source forms: xgdx addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle xgdx (inh) addr data r/ w 1op8f 1 2 op+1 1 3 ffff 1
m68hc11 instruction set details motorola reference manual a-113 xgdy exchange double accumulator and xgdy index register y operation: (iy) t (accd) description: exchanges the contents of double accumulator accd and the contents of index register y. a common use for xgdy is to move an index value into the dou- ble accumulator to allow 16-bit arithmetic calculations on the index value before ex- changed the updated index value back into the y index register. condition codes and boolean formulae: none affected source forms: xgdy addressing modes, machine code, and cycle-by-cycle execution: sxhinzvc cycle xgdy (inh) addr data r/ w 1op18 1 2 op+1 8f 1 3 op+2 1 4 ffff 1
motorola instruction set details m68hc11 a-114 reference manual
m68hc11 bootloader listings motorola reference manual b-1 appendix b bootloader listings this appendix contains source code listings of the internal bootloader roms for sev- eral members of the m68hc11 family. listings of other m68hc11 family bootloader roms can be found in application note an1060. family security option page MC68HC11a8 no bC2 to bC4 MC68HC11a8 yes bC5 to bC8 mc68hc811e2 no bC9 to bC11 mc68hc811e2 yes bC12 to bC16 MC68HC11e9 no bC17 to bC19 MC68HC11e9 yes bC20 to bC24 MC68HC11f1 no bC25 to bC27
motorola bootloader listings m68hc11 b-2 reference manual listing MC68HC11a8 bootloader (no security) sheet 1 of 3 * bootloader firmware for MC68HC11a8 w/o security *************************************************** * thu dec 11 18:46:19 cst 1986 *************************************************** * equates for use with index offset = $1000 0008 portd equ $08 0009 ddrd equ $09 0028 spcr equ $28 (for dwom bit) 002b baud equ $2b 002c sccr1 equ $2c 002d sccr2 equ $2d 002e scsr equ $2e 002f scdat equ $2f 003b pprog equ $3b 003e test1 equ $3e 003f config equ $3f * more equates * b600 eepstr equ $b600 start of eeprom b7ff eepend equ $b7ff end of eeprom ***************************************************** * this bootstrap program allows the user to * download a program of exactly 256 bytes. * the program must start at $0000. * each byte of the program is received by the * sci, starting with the $0000 byte and working * up to the $00ff byte. * * the transmitter will be used for the purpose * of communication to the outside world. ***************************************************** bf40 org $bf40 bf40 begin equ * * init stack bf40 8e 00 ff lds #$00ff * init x reg for indexed access to registers bf43 ce 10 00 ldx #$1000 * put port d in wire or mode bf46 1c 28 20 bset spcr,x $20 * init sci and restart baud divider chain bf49 86 a2 ldaa #$a2 div by 16 bf4b a7 2b staa baud,x * receiver & transmitter enabled bf4d 86 0c ldaa #$0c bf4f a7 2d staa sccr2,x
m68hc11 bootloader listings motorola reference manual b-3 listing - MC68HC11a8 bootloader (no security) sheet 2 of 3 * security code is removed * send break to signal start of download bf51 1c 2d 01 bset sccr2,x $01 * clear break as soon as start bit is detected bf54 1e 08 01 fc brset portd,x $01 * bf58 1d 2d 01 bclr sccr2,x $01 clear break * wait for first character (users send $ff) bf5b 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bf5f a6 2f ldaa scdat,x read data * if data = $00 (break or $00), then jump to eeprom bf61 26 03 bne notzero bf63 7e b6 00 jmp $b600 bf66 notzero equ * * if data = $55, then skip download (test mode) bf66 81 55 cmpa #$55 bf68 27 1e beq star * if data = $ff, then /16 is correct baud bf6a 81 ff cmpa #$ff bf6c 27 03 beq baudok * else change to /104 (/13 & /8) 1200 @ 2mhz bf6e 1c 2b 33 bset baud,x $33 * then download 256 byte program bf71 baudok equ * bf71 18 ce 00 00 ldy #$0000 init pointer * read in program and put into ram bf75 bk2 equ * bf75 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bf79 a6 2f ldaa scdat,x bf7b 18 a7 00 staa $00,y bf7e a7 2f staa scdat,x handshake bf80 18 08 iny * until the end is reached bf82 18 8c 01 00 cpy #$0100 bf86 26 ed bne bk2 ***************************************************** * all start users program * bf88 star equ * bf88 7e 00 00 jmp $0000
motorola bootloader listings m68hc11 b-4 reference manual listing - MC68HC11a8 bootloader (no security) sheet 3 of 3 bfd4 org $bfd4 needed if bootrom < max * mask i. d. byte bfd4 00 00 fdb $0000 ***************************************************** * vectors * bfd6 00 c4 fdb $100-60 sci bfd8 00 c7 fdb $100-57 spi bfda 00 ca fdb $100-54 pulse accum input edge bfdc 00 cd fdb $100-51 pulse accum overflow bfde 00 d0 fdb $100-48 timer overflow bfe0 00 d3 fdb $100-45 timer output compare 5 bfe2 00 d6 fdb $100-42 timer output compare 4 bfe4 00 d9 fdb $100-39 timer output compare 3 bfe6 00 dc fdb $100-36 timer output compare 2 bfe8 00 df fdb $100-33 timer output compare 1 bfea 00 e2 fdb $100-30 timer input capture 3 bfec 00 e5 fdb $100-27 timer input capture 2 bfee 00 e8 fdb $100-24 timer input capture 1 bff0 00 eb fdb $100-21 real time int bff2 00 ee fdb $100-18 irq bff4 00 f1 fdb $100-15 xirq bff6 00 f4 fdb $100-12 swi bff8 00 f7 fdb $100-9 illegal op-code bffa 00 fa fdb $100-6 cop fail bffc 00 fd fdb $100-3 clock monitor bffe bf 40 fdb #begin reset ***************************************************** * end *****************************************************
m68hc11 bootloader listings motorola reference manual b-5 listing MC68HC11a8 bootloader (with security) sheet 1 of 4 * bootloader firmware for MC68HC11a8 (with security) ***************************************************** * wed dec 5 16:14:54 cst 1984 ***************************************************** * equates for use with index offset = $1000 0008 portd equ $08 0009 ddrd equ $09 0028 spcr equ $28 (for dwom bit) 002b baud equ $2b 002c sccr1 equ $2c 002d sccr2 equ $2d 002e scsr equ $2e 002f scdat equ $2f 003b pprog equ $3b 003e test1 equ $3e 003f config equ $3f * more equates * b600 eepstr equ $b600 start of eeprom b7ff eepend equ $b7ff end of eeprom ***************************************************** * this bootstrap program allows the user to * download a program of exactly 256 bytes. * the program must start at $0000. * each byte of the program is received by the * sci, starting with the $0000 byte and working * up to the $00ff byte. * * the transmitter will be used for the purpose * of communication to the outside world. ***************************************************** bf40 org $bf40 bf40 begin equ * * init stack bf40 8e 00 ff lds #$00ff * init x reg for indexed access to registers bf43 ce 10 00 ldx #$1000 * put port d in wire or mode bf46 1c 28 20 bset spcr,x $20 * init sci and restart baud divider chain bf49 86 a2 ldaa #$a2 div by 16 bf4b a7 2b staa baud,x * receiver & transmitter enabled bf4d 86 0c ldaa #$0c bf4f a7 2d staa sccr2,x
motorola bootloader listings m68hc11 b-6 reference manual listing - MC68HC11a8 bootloader (with security) sheet 2 of 4 * test the security bit bf51 1e 3f 08 34 brset config,x $08 nosec *************************************************** * we are in security mode * output $ff on transmitter bf55 again equ * bf55 a6 2e ldaa scsr,x bf57 86 ff ldaa #$ff bf59 a7 2f staa scdat,x * erase eeprom: * set erase and eelat bits before using "erase" bf5b c6 06 ldab #$06 bf5d e7 3b stab pprog,x bf5f f7 b6 00 stab eepstr write any eeprom location bf62 8d 5f bsr erase * accb is now set for $06 ******** * erase cycle is complete * if the ee is disabled (eeon=0), skip ee chk * we cant check that the eeprom is erased bf64 1f 3f 01 11 brclr config,x $01 noee * eeprom is enabled (eeon=1), * now check that the eeprom is erased bf68 18 ce b6 00 ldy #eepstr bf6c loop equ * bf6c 18 a1 00 cmpa 0,y (a=$ff) * any unerased byte sends us back to erase again bf6f 26 e4 bne again bf71 18 08 iny bf73 18 8c bb 00 cpy #eepend+1 bf77 26 f3 bne loop bf79 noee equ * ***************************************************** * write $ff to entire ram (except last two bytes * which are used by the stack) bf79 eram equ * bf79 3c pshx bf7a ce ff 02 ldx #$ff02 bf7d lop1 equ * bf7d a7 fe staa $fe,x bf7f 08 inx bf80 26 fb bne lop1 bf82 38 pulx
m68hc11 bootloader listings motorola reference manual b-7 listing - MC68HC11a8 bootloader (with security) sheet 3 of 4 ***************************************************** * now erase config register bf83 econfg equ * * set erase and eelat bits bf83 e7 3b stab pprog,x (b still = $06) * write config register, latch addr for erasure bf85 e7 3f stab config,x bf87 8d 3a bsr erase * erase cycle is complete ***************************************************** * non-security and security modes meet here bf89 nosec equ * * send break to signal start of download bf89 1c 2d 01 bset sccr2,x $01 * clear break as soon as start bit is detected bf8c 1e 08 01 fc brset portd,x $01 * bf90 1d 2d 01 bclr sccr2,x $01 clear break * wait for first character (users send $ff) bf93 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bf97 a6 2f ldaa scdat,x read data * if data = $00 (break or $00), then jump to eeprom bf99 26 03 bne notzero bf9b 7e b6 00 jmp $b600 bf9e notzero equ * * if data = $55, then skip download (test mode) bf9e 81 55 cmpa #$55 bfa0 27 1e beq star * if data = $ff, then /16 is correct baud bfa2 81 ff cmpa #$ff bfa4 27 03 beq baudok * else change to /104 (/13 & /8) 1200 @ 2mhz bfa6 1c 2b 33 bset baud,x $33 * then download 256 byte program bfa9 baudok equ * bfa9 18 ce 00 00 ldy #$0000 init pointer * read in program and put into ram bfad bk2 equ * bfad 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bfb1 a6 2f ldaa scdat,x bfb3 18 a7 00 staa $00,y bfb6 a7 2f staa scdat,x handshake bfb8 18 08 iny bfba 18 8c 01 00 cpy #$0100 until the end is reached bfbe 26 ed bne bk2 ******************************************************* * all start users program bfc0 star equ * bfc0 7e 00 00 jmp $0000
motorola bootloader listings m68hc11 b-8 reference manual listing - MC68HC11a8 bootloader (with security) sheet 4 of 4 ***************************************************** * eeprom erase subroutine * * assumes calling routine has already set erase * and eelat bits, as well as accessed config reg * if that is to be erased * * entry x = $1000 * exit x = $1000, y = $0000 bfc3 erase equ * * set eepgm bit bfc3 1c 3b 01 bset pprog,x $01 * 10 millisec delay @ 2.1 mhz bfc6 18 ce 0b bb ldy #3000 bfca 18 09 bk1 dey bfcc 26 fc bne bk1 * turn off eepgm bit; then "erase & eelat" bits bfce 1d 3b 01 bclr pprog,x $01 bfd1 6f 3b clr pprog,x bfd3 39 rts * mask i. d. byte bfd4 00 00 fdb $0000 ***************************************************** * vectors * org $bfd6 needed if bootrom < max bfd6 00 c4 fdb $100-60 sci bfd8 00 c7 fdb $100-57 spi bfda 00 ca fdb $100-54 pulse accum input edge bfdc 00 cd fdb $100-51 pulse accum overflow bfde 00 d0 fdb $100-48 timer overflow bfe0 00 d3 fdb $100-45 timer output compare 5 bfe2 00 d6 fdb $100-42 timer output compare 4 bfe4 00 d9 fdb $100-39 timer output compare 3 bfe6 00 dc fdb $100-36 timer output compare 2 bfe8 00 df fdb $100-33 timer output compare 1 bfea 00 e2 fdb $100-30 timer input capture 3 bfec 00 e5 fdb $100-27 timer input capture 2 bfee 00 e8 fdb $100-24 timer input capture 1 bff0 00 eb fdb $100-21 real time int bff2 00 ee fdb $100-18 irq bff4 00 f1 fdb $100-15 xirq bff6 00 f4 fdb $100-12 swi bff8 00 f7 fdb $100-9 illegal op-code bffa 00 fa fdb $100-6 cop fail bffc 00 fd fdb $100-3 clock monitor bffe bf 40 fdb #begin reset * end
m68hc11 bootloader listings motorola reference manual b-9 listing mc68hc811e2 bootloader (no security) sheet 1 of 3 * bootloader firmware for 68hc11e2 ***************************************************** * mon jan 11 16:06:00 cst 1988 ***************************************************** * equates for use with index offset = $1000 0008 portd equ $08 0009 ddrd equ $09 0028 spcr equ $28 (for dwom bit) 002b baud equ $2b 002c sccr1 equ $2c 002d sccr2 equ $2d 002e scsr equ $2e 002f scdat equ $2f 003b pprog equ $3b 003e test1 equ $3e 003f config equ $3f * more equates * f800 eepstr equ $f800 start of eeprom ffff eepend equ $ffff end of eeprom ***************************************************** * this bootstrap program allows the user to * download a program of exactly 256 bytes. * the program must start at $0000. * each byte of the program is received by the * sci, starting with the $0000 byte and working * up to the $00ff byte. * * the transmitter will be used for the purpose * of communication to the outside world. ******** * this program was kept as much the same as * the 68hc11a8 bootloader as possible. ***************************************************** bf40 org $bf40 bf40 begin equ * * init stack bf40 8e 00 ff lds #$00ff * init x reg for indexed access to registers bf43 ce 10 00 ldx #$1000 ******** * put port d in wire or mode bf46 1c 28 20 bset spcr,x $20
motorola bootloader listings m68hc11 b-10 reference manual listing - mc68hc811e2 bootloader (no security) sheet 2 of 3 * init sci and restart baud divider chain bf49 86 a2 ldaa #$a2 div by 16 bf4b a7 2b staa baud,x * receiver & transmitter enabled bf4d 86 0c ldaa #$0c bf4f a7 2d staa sccr2,x ******** * send break to signal start of download bf51 1c 2d 01 bset sccr2,x $01 * clear break as soon as start bit is detected bf54 1e 08 01 fc brset portd,x $01 * bf58 1d 2d 01 bclr sccr2,x $01 clear break * wait for first character (users send $ff) bf5b 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bf5f a6 2f ldaa scdat,x read data * if data = $00 (break or $00), then jump to eeprom bf61 26 03 bne notzero bf63 7e f8 00 jmp eepstr bf66 notzero equ * * if data = $55, then skip download (test mode) bf66 81 55 cmpa #$55 bf68 27 1e beq star * if data = $ff, then /16 is correct baud bf6a 81 ff cmpa #$ff bf6c 27 03 beq baudok * else change to /104 (/13 & /8) 1200 @ 2mhz bf6e 1c 2b 33 bset baud,x $33 * then download 256 byte program bf71 baudok equ * bf71 18 ce 00 00 ldy #$0000 init pointer * read in program and put into ram bf75 bk2 equ * bf75 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bf79 a6 2f ldaa scdat,x bf7b 18 a7 00 staa $00,y bf7e a7 2f staa scdat,x handshake bf80 18 08 iny * until the end is reached bf82 18 8c 01 00 cpy #$0100 bf86 26 ed bne bk2 ***************************************************** * all start users program bf88 star equ * bf88 7e 00 00 jmp $0000
m68hc11 bootloader listings motorola reference manual b-11 listing - mc68hc811e2 bootloader (no security) sheet 3 of 3 bfd4 org $bfd4 needed if bootrom < max ***************************************************** * mask i.d. for 811e2 with no security bfd4 e2 e2 fdb $e2e2 ***************************************************** * vectors * bfd6 00 c4 fdb $100-60 sci bfd8 00 c7 fdb $100-57 spi bfda 00 ca fdb $100-54 pulse accum input edge bfdc 00 cd fdb $100-51 pulse accum overflow bfde 00 d0 fdb $100-48 timer overflow bfe0 00 d3 fdb $100-45 timer output compare 5 bfe2 00 d6 fdb $100-42 timer output compare 4 bfe4 00 d9 fdb $100-39 timer output compare 3 bfe6 00 dc fdb $100-36 timer output compare 2 bfe8 00 df fdb $100-33 timer output compare 1 bfea 00 e2 fdb $100-30 timer input capture 3 bfec 00 e5 fdb $100-27 timer input capture 2 bfee 00 e8 fdb $100-24 timer input capture 1 bff0 00 eb fdb $100-21 real time int bff2 00 ee fdb $100-18 irq bff4 00 f1 fdb $100-15 xirq bff6 00 f4 fdb $100-12 swi bff8 00 f7 fdb $100-9 illegal op-code bffa 00 fa fdb $100-6 cop fail bffc 00 fd fdb $100-3 clock monitor bffe bf 40 fdb $bf40 reset * end
motorola bootloader listings m68hc11 b-12 reference manual listing mc68hc811e2 bootloader (with security) sheet 1 of 5 * bootloader firmware for 68hc11e2 - secured version ***************************************************** * tue oct 25 11:38:07 cdt 1988 ***************************************************** * equates for use with index offset = $1000 0008 portd equ $08 0009 ddrd equ $09 0028 spcr equ $28 (for dwom bit) 002b baud equ $2b 002c sccr1 equ $2c 002d sccr2 equ $2d 002e scsr equ $2e 002f scdat equ $2f 0035 bprot equ $35 003b pprog equ $3b 003e test1 equ $3e 003f config equ $3f * more equates * f800 eepstr equ $f800 start of eeprom ffff eepend equ $ffff end of eeprom ***************************************************** * this bootstrap program allows the user to * download a program of exactly 256 bytes. * the program must start at $0000. * each byte of the program is received by the * sci, starting with the $0000 byte and working * up to the $00ff byte. * * the transmitter will be used for the purpose * of communication to the outside world. ******** * this program was kept as much the same as * the 68hc11a8 bootloader as possible. ***************************************************** bf40 org $bf40 bf40 begin equ * * init stack bf40 8e 00 ff lds #$00ff * init x reg for indexed access to registers bf43 ce 10 00 ldx #$1000 * put port d in wire or mode bf46 1c 28 20 bset spcr,x $20
m68hc11 bootloader listings motorola reference manual b-13 listing - mc68hc811e2 bootloader (with security) sheet 2 of 5 * init sci and restart baud divider chain bf49 86 a2 ldaa #$a2 div by 16 bf4b a7 2b staa baud,x * receiver & transmitter enabled bf4d 86 0c ldaa #$0c bf4f a7 2d staa sccr2,x * test the security bit bf51 1e 3f 08 36 brset config,x $08 nosec ***************************************************** * we are in security mode * output $ff on transmitter bf55 again equ * bf55 a6 2e ldaa scsr,x bf57 86 ff ldaa #$ff bf59 a7 2f staa scdat,x * erase eeprom: * turn off block protect bf5b 6f 35 clr bprot,x * set erase and eelat bits before using "erase" bf5d c6 06 ldab #$06 bf5f e7 3b stab pprog,x bf61 f7 f8 00 stab eepstr write eeprom location bf64 8d 5f bsr erase * accb is now set for $06 ******** * erase cycle is complete * * if the eeprom is not enabled * we cant check that the eeprom is erased bf66 1f 3f 01 11 brclr config,x $01 noee * eeprom is on, * now check that the eeprom is erased bf6a 18 ce f8 00 ldy #eepstr bf6e loop equ * bf6e 18 a1 00 cmpa 0,y (a = $ff) * any unerased byte sends us back to erase again bf71 26 e2 bne again bf73 18 08 iny bf75 18 8c 00 00 cpy #eepend+1 bf79 26 f3 bne loop bf7b noee equ *
motorola bootloader listings m68hc11 b-14 reference manual listing - mc68hc811e2 bootloader (with security) sheet 3 of 5 ***************************************************** * write $ff to entire ram (except last two bytes * which are used by the stack) bf7b eram equ * bf7b 3c pshx bf7c ce ff 02 ldx #$ff02 bf7f lop1 equ * bf7f a7 fe staa $fe,x bf81 08 inx bf82 26 fb bne lop1 bf84 38 pulx ***************************************************** * now erase config register bf85 econfg equ * * set erase and eelat bits bf85 e7 3b stab pprog,x (b still = $06) * write config register latch it for erasure bf87 e7 3f stab config,x bf89 8d 3a bsr erase * erase cycle is complete ***************************************************** * non-security and security modes meet here * bf8b nosec equ * * send break to signal start of download bf8b 1c 2d 01 bset sccr2,x $01 * clear break as soon as start bit is detected bf8e 1e 08 01 fc brset portd,x $01 * bf92 1d 2d 01 bclr sccr2,x $01 clear break * wait for first character (users send $ff) bf95 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bf99 a6 2f ldaa scdat,x read data * if data = $00 (break or $00), then jump to eeprom bf9b 26 03 bne notzero bf9d 7e f8 00 jmp eepstr bfa0 notzero equ * * if data = $55, then skip download (test mode) bfa0 81 55 cmpa #$55 bfa2 27 1e beq star
m68hc11 bootloader listings motorola reference manual b-15 listing - mc68hc811e2 bootloader (with security) sheet 4 of 5 * if data = $ff, then /16 is correct baud bfa4 81 ff cmpa #$ff bfa6 27 03 beq baudok * else change to /104 (/13 &/8) 1200 @ 2mhz bfa8 1c 2b 33 bset baud,x $33 * then download 256 byte program bfab baudok equ * bfab 18 ce 00 00 ldy #$0000 init pointer * read in program and put into ram bfaf bk2 equ * bfaf 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bfb3 a6 2f ldaa scdat,x bfb5 18 a7 00 staa $00,y bfb8 a7 2f staa scdat,x handshake bfba 18 08 iny * until the end is reached bfbc 18 8c 01 00 cpy #$0100 bfc0 26 ed bne bk2 ************************************************* * all start users program bfc2 star equ * bfc2 7e 00 00 jmp $0000 ***************************************************** * eeprom erase subroutine * * assumes calling routine has already set erase * and eelat bits, as well as accessed config reg * if that is to be erased * * entry x = $1000 * exit x = $1000, y = $0000 bfc5 erase equ * * set eepgm bit bfc5 1c 3b 01 bset pprog,x $01 * 10 millisec delay @ 2.1 mhz bfc8 18 ce 0b b8 ldy #3000 bfcc 18 09 bk1 dey bfce 26 fc bne bk1 * turn off eepgm, erase and eelat bits bfd0 6f 3b clr pprog,x bfd2 39 rts
motorola bootloader listings m68hc11 b-16 reference manual listing - mc68hc811e2 bootloader (with security) sheet 5 of 5 bfd4 org $bfd4 needed if bootrom < max ***************************************************** * mask i.d. for 811e2 with security bfd4 e2 5c fdb $e25c (5c=sc for security) ***************************************************** * vectors bfd6 00 c4 fdb $100-60 sci bfd8 00 c7 fdb $100-57 spi bfda 00 ca fdb $100-54 pulse accum input edge bfdc 00 cd fdb $100-51 pulse accum overflow bfde 00 d0 fdb $100-48 timer overflow bfe0 00 d3 fdb $100-45 timer output compare 5 bfe2 00 d6 fdb $100-42 timer output compare 4 bfe4 00 d9 fdb $100-39 timer output compare 3 bfe6 00 dc fdb $100-36 timer output compare 2 bfe8 00 df fdb $100-33 timer output compare 1 bfea 00 e2 fdb $100-30 timer input capture 3 bfec 00 e5 fdb $100-27 timer input capture 2 bfee 00 e8 fdb $100-24 timer input capture 1 bff0 00 eb fdb $100-21 real time int bff2 00 ee fdb $100-18 irq bff4 00 f1 fdb $100-15 xirq bff6 00 f4 fdb $100-12 swi bff8 00 f7 fdb $100-9 illegal op-code bffa 00 fa fdb $100-6 cop fail bffc 00 fd fdb $100-3 clock monitor bffe bf 40 fdb $bf40 reset * end
m68hc11 bootloader listings motorola reference manual b-17 listing MC68HC11e9 bootloader (no security) sheet 1 of 3 * bootloader firmware for 68hc11e9 - no security ***************************************************** * tue jan 12 17:08:00 cst 1988 ***************************************************** ***************************************************** * this new version allows variable length download * by quitting reception of characters when an idle * of at least four word times occurs ***************************************************** * equates for use with index offset = $1000 0008 portd equ $08 0009 ddrd equ $09 0016 toc1 equ $16 [extra storage (poor style)] 0028 spcr equ $28 (for dwom bit) 002b baud equ $2b 002c sccr1 equ $2c 002d sccr2 equ $2d 002e scsr equ $2e 002f scdat equ $2f 003b pprog equ $3b 003e test1 equ $3e 003f config equ $3f * more equates * b600 eepstr equ $b600 start of eeprom b7ff eepend equ $b7ff end of eeprom 0000 ramstr equ $0000 01ff ramend equ $01ff 0db0 delays equ 3504 delay at slow baud 021b delayf equ 539 delay at fast baud ***************************************************** * this bootstrap program allows the user to * download a program of 0 - 512 bytes. * the program must start at $0000. * each byte of the program is received by the sci. * the first byte establishes baud rate. * then the program is downloaded starting with * the $0000 byte and working up toward the $01ff * a delay of four word times (at either baud rate) * causes the reception of characters to stop and * a jump to $0000. * * the transmitter will be used for the purpose * of communication to the outside world. *****************************************************
motorola bootloader listings m68hc11 b-18 reference manual listing - MC68HC11e9 bootloader (no security) sheet 2 of 3 bf40 org $bf40 bf40 begin equ * * init stack bf40 8e 01 ff lds #ramend * init x reg for indexed access to registers bf43 ce 10 00 ldx #$1000 * put port d in wire or mode bf46 1c 28 20 bset spcr,x $20 * init sci and restart baud divider chain bf49 cc a2 0c ldd #$a20c div by 16 bf4c a7 2b staa baud,x * receiver & transmitter enabled bf4e e7 2d stab sccr2,x * set up delay for fastest baud rate bf50 cc 02 1b ldd #delayf bf53 ed 16 std toc1,x * send break to signal start of download bf55 1c 2d 01 bset sccr2,x $01 * clear break as soon as start bit is detected bf58 1e 08 01 fc brset portd,x $01 * bf5c 1d 2d 01 bclr sccr2,x $01 clear break * wait for first character (users send $ff) bf5f 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bf63 a6 2f ldaa scdat,x read data * if data = $00 (break or $00), then jump to eeprom bf65 26 03 bne notzero bf67 7e b6 00 jmp eepstr bf6a notzero equ * * if data = $ff, then /16 is correct baud bf6a 81 ff cmpa #$ff bf6c 27 08 beq baudok * else change to /104 (/13 & /8) 1200 @ 2mhz bf6e 1c 2b 33 bset baud,x $33 * set up delay for slower baud rate bf71 cc 0d b0 ldd #delays bf74 ed 16 std toc1,x bf76 baudok equ * bf76 18 ce 00 00 ldy #ramstr pointer to start of ram
m68hc11 bootloader listings motorola reference manual b-19 listing - MC68HC11e9 bootloader (no security) sheet 3 of 3 * time each byte bf7a ec 16 wait ldd toc1,x put delay time in accd bf7c 1e 2e 20 07 wtloop brset scsr,x $20 newone bfb0 bf xgdx delay into x bf81 09 dex decrement delay bf82 8f xgdx return delay to accd bf83 26 f7 bne wtloop bf85 20 0f bra star did not time out * read in byte and put into ram bf87 a6 2f newone ldaa scdat,x bf89 18 a7 00 staa $00,y bf8c a7 2f staa scdat,x handshake bf8e 18 08 iny bf90 18 8c 02 00 cpy #ramend+1 bf94 26 e4 bne wait *************************************************************** * all start users program bf96 star equ * bf96 7e 00 00 jmp ramstr bfd2 org $bfd2 *************************************************************** * mask i.d. # bfd2 00 00 fdb $0000 bfd4 e9 e9 fdb $e9e9 e9 i.d. *************************************************************** * vectors * bfd6 00 c4 fdb $100-60 sci bfd8 00 c7 fdb $100-57 spi bfda 00 ca fdb $100-54 pulse accum input edge bfdc 00 cd fdb $100-51 pulse accum overflow bfde 00 d0 fdb $100-48 timer overflow bfe0 00 d3 fdb $100-45 timer output compare 5 bfe2 00 d6 fdb $100-42 timer output compare 4 bfe4 00 d9 fdb $100-39 timer output compare 3 bfe6 00 dc fdb $100-36 timer output compare 2 bfe8 00 df fdb $100-33 timer output compare 1 bfea 00 e2 fdb $100-30 timer input capture 3 bfec 00 e5 fdb $100-27 timer input capture 2 bfee 00 e8 fdb $100-24 timer input capture 1 bff0 00 eb fdb $100-21 real time int bff2 00 ee fdb $100-18 irq bff4 00 f1 fdb $100-15 xirq bff6 00 f4 fdb $100-12 swi bff8 00 f7 fdb $100-9 illegal op-code bffa 00 fa fdb $100-6 cop fail bffc 00 fd fdb $100-3 clock monitor bffe bf 40 fdb #begin reset * end
motorola bootloader listings m68hc11 b-20 reference manual listing MC68HC11e9 bootloader (with security) sheet 1 of 5 * bootloader firmware for 68hc11e9 - secured version ******************************************************* * tue oct 25 16:38:50 cdt 1988 ******************************************************* ******************************************************* * this new version allows variable length download * by quitting reception of characters when an idle * of at least four word times occurs ******************************************************* * equates for use with index offset = $1000 0008 portd equ $08 0009 ddrd equ $09 0016 toc1 equ $16 (extra storage (poor style)] 0028 spcr equ $28 (for dwom bit) 002b baud equ $2b 002c sccr1 equ $2c 002d sccr2 equ $2d 002e scsr equ $2e 002f scdat equ $2f 0035 bprot equ $35 003b pprog equ $3b 003e test1 equ $3e 003f config equ $3f * more equates * b600 eepstr equ $b600 start of eeprom b7ff eepend equ $b7ff end of eeprom 0000 ramstr equ $0000 01ff ramend equ $01ff 0db0 delays equ 3504 delay at slow baud 021b delayf equ 539 delay at fast baud ******************************************************* * this bootstrap program allows the user to * download a program of 0 - 512 bytes. * the program must start at $0000. * each byte of the program is received by the sci. * the first byte establishes baud rate. * then the program is downloaded starting with * the $0000 byte and working up toward the $01ff * a delay of four word times (at either baud rate) * causes the reception of characters to stop and * a jump to $0000. * * sci transmitter used to echo to outside world *******************************************************
m68hc11 bootloader listings motorola reference manual b-21 listing - MC68HC11e9 bootloader (with security) sheet 2 of 5 bf40 org $bf40 bf40 begin equ * * init stack bf40 8e 01 ff lds #$01ff * init x reg for indexed access to registers bf43 ce 10 00 ldx #$1000 * put port d in wire or mode bf46 1c 28 20 bset spcr,x$20 * init sci and restart baud divider chain bf49 cc a2 0c ldd #$a20c div by 16 bf4c a7 2b staa baud,x * receiver & transmitter enabled bf4e e7 2d stab sccr2,x * test the security bit bf50 1e 3f 08 35 brset config,x $08 nosec ***************************************************** * we are in security mode * output $ff on transmitter bf54 again equ * bf54 a6 2e ldaa scsr,x bf56 86 ff ldaa #$ff bf58 a7 2f staa scdat,x * acca now is set for $ff * erase eeprom: * turn off block protect bf5a 6f 35 clr bprot,x * set erase and eelat bits before using "erase" bf5c 54 lsrb change $0c to $06 bf5d e7 3b stab pprog,x bf5f f7 b6 00 stab eepstr write eeprom location bf62 8d 72 bsr erase * accb is now set for $06 * erase cycle is complete * if the eeprom is not enabled, * we cant check that the eeprom is erased bf64 1f 3f 01 11 brclr config,x $01 noee * eeprom is on, * now check that the eeprom is erased bf68 18 ce b6 00 ldy #eepstr bf6c loop equ * bf6c 18 a1 00 cmpa 0,y (a = $ff) * any unerased byte sends us back to erase again bf6f 26 e3 bne again bf71 18 08 iny bf73 18 8c b8 00 cpy #eepend+1 bf77 26 f3 bne loop
motorola bootloader listings m68hc11 b-22 reference manual listing - MC68HC11e9 bootloader (with security) sheet 3 of 5 bf79 noee equ * ******************************************************* * write over entire ram, except last two bytes which * are used by the stack & $0000 which is left intact bf79 eram equ * bf79 3c pshx bf7a ce 01 fd ldx #ramend-2 bf7d lop1 equ * bf7d a7 00 staa $00,x bf7f 09 dex bf80 26 fb bne lop1 bf82 38 pulx ******************************************************* * now erase config register bf83 econfg equ * * set erase and eelat bits bf83 e7 3b stab pprog,x (b still = $06) * write config register latch it for erasure bf85 e7 3f stab config,x bf87 bd 4d bsr erase * erase cycle is complete ***************************************************** * non-security and security modes meet here * bf89 nosec equ * * set up delay for fastest baud rate bf89 cc 02 1b ldd #delayf bf8c ed 16 std toc1,x * send break to signal start of download bf8e 1c 2d 01 bset sccr2,x $01 * clear break as soon as start bit is detected bf91 1e 08 01 fc brset portd,x $01 * bf95 1d 2d 01 bclr sccr2,x $01 clear break * wait for first character (users send $ff) bf98 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bf9c a6 2f ldaa scdat,x read data * if data = $00 (break or $00), then jump to eeprom bf9e 26 03 bne notzero bfa0 7e b6 00 jmp eepstr bfa3 notzero equ * * if data - $ff, then /16 is correct baud bfa3 81 ff cmpa #$ff bfa5 27 08 beq baudok
m68hc11 bootloader listings motorola reference manual b-23 listing - MC68HC11e9 bootloader (with security) sheet 4 of 5 * else change to /104 (/13 &/8) 1200 @ 2mhz bfa7 1c 2b 33 bset baud,x$33 * set up delay for slower baud rate bfaa cc 0d b0 ldd #delays bfad ed 16 std toc1,x bfaf baudok equ * bfaf 18 ce 00 00 ldy #ramstr pointer to start of ram * time each byte bfb3 ec 16 wait ldd toc1,x put delay time in accd bfb5 1e 2e 20 07 wtloop brset scsr,x $20 newone bfb9 8f xgdx delay into x bfba 09 dex decrement delay bfbb 8f xgdx return delay to accd bfbc 26 f7 bne wtloop bfbe 20 0f bra star bfc0 newone equ * * did not time out so read in byte and put into ram bfc0 a6 2f ldaa scdat,x bfc2 18 a7 00 staa $00,y bfc5 a7 2f staa scdat,x handshake bfc7 18 08 iny bfc9 18 8c 02 00 cpy #ramend+1 bfcd 26 e4 bne wait ***************************************************** * all start users program bfcf star equ * bfcf 7e 00 00 jmp ramstr bfd2 org $bfd2 ***************************************************** * mask i.d. # bfd2 00 00 fdb $0000 bfd4 e9 5c fdb $e95c e9 i.d.(5c=sc for security) ***************************************************** * eeprom erase subroutine * * assumes calling routine has already set erase and * eelat bits and has accessed whatever is to be erased * * entry x=$1000 * exit x=$1000, y=$0000 bfd6 erase equ* bfd6 1c 3b 01 bset pprog,x $01 set eepgm bit * 10 millisec delay @ 2.1 mhz bfd9 18 ce 0b b8 ldy #3000 bfdd 18 09 bk1 dey bfdf 26 fc bne bk1 bfe1 6f 3b clr pprog,x clear erase & eelat bits bfe3 39 rts
motorola bootloader listings m68hc11 b-24 reference manual listing - MC68HC11e9 bootloader (with security) sheet 5 of 5 ***************************************************** *vectors (first seven dont point to ram) * * fdb $100-60 sci * fdb $100-57 spi * fdb $100-54 pulse accum input edge * fdb $100-51 pulse accum overflow * fdb $100-48 timer overflow * fdb $100-45 timer output compare 5 * fdb $100-42 timer output compare 4 bfe4 00 d9 fdb $100-39 timer output compare 3 bfe6 00 dc fdb $100-36 timer output compare 2 bfeb 00 df fdb $100-33 timer output compare 1 bfea 00 e2 fdb $100-30 timer input capture 3 bfec 00 e5 fdb $100-27 timer input capture 2 bfee 00 e8 fdb $100-24 timer input capture 1 bff0 00 eb fdb $100-21 real time int bff2 00 ee fdb $100-18 irq bff4 00 f1 fdb $100-15 xirq bff6 00 f4 fdb $100-12 swi bff8 00 f7 fdb $100-9 illegal op-code bffa 00 fa fdb $100-6 cop fail bffc 00 fd fdb $100-3 clock monitor bffe bf 40 fdb #$bf40 reset * end
m68hc11 bootloader listings motorola reference manual b-25 listing - MC68HC11f1 bootloader sheet 1 of 3 * bootloader firmware for 68hc11f1 - no security ***************************************************** * thr mar 10 08:49:00 cst 1988 ***************************************************** ***************************************************** * this new version allows variable length download * by quitting reception of characters when an idle * of at least four word times occurs ***************************************************** * equates for use with index offset = $1000 0008 portd equ $08 0009 ddrd equ $09 0016 toc1 equ $16 (extra storage (poor style)] 0028 spcr equ $28 (for dwom bit) 002b baud equ $2b 002c sccr1 equ $2c 002d sccr2 equ $2d 002e scsr equ $2e 002f scdat equ $2f 003b pprog equ $3b 003e test1 equ $3e 003f config equ $3f * more equates * fe00 eepstr equ $fe00 start of eeprom ffff eepend equ $ffff end of eeprom 0000 ramstr equ $0000 03ff ramend equ $03ff 0db0 delays equ 3504 delay at slow baud 021b delayf equ 539 delay at fast baud ***************************************************** * this bootstrap program allows the user to * download a program of 0 - 1024 bytes. * the program must start at $0000. * each byte of the program is received by the sci. * the first byte establishes baud rate. * then the program is downloaded starting with * the $0000 byte and working up toward the $03ff * a delay of four word times (at either baud rate) * causes the reception of characters to stop and * a jump to $0000. * * the transmitter will be used for the purpose * of communication to the outside world. *****************************************************
motorola bootloader listings m68hc11 b-26 reference manual listing - MC68HC11f1 bootloader sheet 2 of 3 bf00 org $bf00 bf00 begin equ * * init stack bf00 8e 03 ff lds #ramend * init x reg for indexed access to registers bf03 ce 10 00 ldx #$1000 * put port d in wire or mode bf06 1c 28 20 bset spcr,x $20 * init sci and restart baud divider chain bf09 cc a2 0c ldd #$a20c div by 16 bf0c a7 2b staa baud,x * receiver & transmitter enabled bf0e e7 2d stab sccr2,x * set up delay for fastest baud rate bf10 cc 02 1b ldd #delayf bf13 ed 16 std toc1,x * send break to signal start of download bf15 1c 2d 01 bset sccr2,x $01 * clear break as soon as start bit is detected bf18 1e 08 01 fc brset portd,x $01 * bf1c 1d 2d 01 bclr sccr2,x $01 clear break * wait for first character (users send $ff) bf1f 1f 2e 20 fc brclr scsr,x $20 * wait for rdrf bf23 a6 2f ldaa scdat,x read data * if data = $00 (break or $00), then jump to eeprom bf25 26 03 bne notzero bf27 7e fe 00 jmp eepstr bf2a notzero equ * * if data = $ff, then /16 is correct baud bf2a 81 ff cmpa #$ff bf2c 27 08 beq baudok * else change to /104 (/13 & /8) 1200 @ 2mhz bf2e 1c 2b 33 bset baud,x $33 * set up delay for slower baud rate bf31 cc 0d b0 ldd #delays bf34 ed 16 std toc1,x * bf36 baudok equ * bf36 18 ce 00 00 ldy #ramstr pointer to start of ram
m68hc11 bootloader listings motorola reference manual b-27 listing - MC68HC11f1 bootloader sheet 3 of 3 * time each byte bf3a ec 16 wait ldd toc1,x put delay time in accd bf3c 1e 2e 20 07 wtloop brset scsr,x$20 newone bf40 8f xgdx delay into x bf41 09 dex decrement delay bf42 8f xgdx return delay to accd bf43 26 f7 bne wtloop bf45 20 0f bra star * did not time out so read in byte and put into ram bf47 a6 2f newone ldaa scdat,x bf49 18 a7 00 staa $00,y bf4c a7 2f staa scdat,x handshake bf4e 18 08 iny bf50 18 8c 04 00 cpy #ramend+1 bf54 26 e4 bne wait ***************************************************** * all start users program bf56 star equ * bf56 7e 00 00 jmp ramstr bfd4 org $bfd4 ***************************************************** * f1 mask i.d. bfd4 f1 f1 fdb $f1f1 ***************************************************** * vectors * bfd6 00 c4 fdb $100-60 sci bfd8 00 c7 fdb $100-57 spi bfda 00 ca fdb $100-54 pulse accum input edge bfdc 00 cd fdb $100-51 pulse accum overflow bfde 00 d0 fdb $100-48 timer overflow bfe0 00 d3 fdb $100-45 timer output compare 5 bfe2 00 d6 fdb $100-42 timer output compare 4 bfe4 00 d9 fdb $100-39 timer outputc ompare 3 bfe6 00 dc fdb $100-36 timer output compare 2 bfe8 00 df fdb $100-33 timer output compare 1 bfea 00 e2 fdb $100-30 timer input capture 3 bfec 00 e5 fdb $100-27 timer input capture 2 bfee 00 e8 fdb $100-24 timer input capture 1 bff0 00 eb fdb $100-21 real time int bff2 00 ee fdb $100-18 irq bff4 00 f1 fdb $100-15 xirq bff6 00 f4 fdb $100-12 swi bff8 00 f7 fdb $100-9 illegal op-code bffa 00 fa fdb $100-6 cop fail bffc 00 fd fdb $100-3 clock monitor bffe bf 00 fdb #begin reset * end
motorola bootloader listings m68hc11 b-28 reference manual
m68hc11 motorola reference manual i-1 index CaC a/d a/d charge pump 12-13 a/d accuracy 2-18, 12-1, 12-7, 12-14, 12-17 a/d conversion 2-27, 4-10, 7-40, 12-1, 12-13, 12-14, 12-15, 12-18 a/d converter reference voltage 2-18, 2-22, 7-39 a/d pin 2-22, 2-27, 12-17, 12-18 a/d system 2-18, 4-10, 5-3, 7-39, 12-1, 12-13, 12-14, 12-18 accumulator 1-2, 2-19, 3-18, 4-16, 5-3, 5-12, 5-22, 5-25, 5-27, 6-1, 6-9, 6-11, 7-1, 7-7, 9-6, 10-2, 10-5, 10-6, 10-20, 10-35, 11-1, 11-2, 11-3, 11-4, 11-5, 11-6, 11-7, 11-8, 11-9, 11-11 adaptive algorithm 4-20 adctl register (registers) 2-3, 2-8, 2-14, 4-2, 4-7, 4-22, 5-1, 5-2, 5-22, 5-25, 5-28, 6-8, 6-13, 7-7, 7-8, 7-46, 9-1, 9-6, 9-9, 9-15, 9-29, 11-2, 11-6, 11-7, 11-11, 12-1, 12-18, 12-21 addres decoding 2-33 address line 2-33, 7-14, 7-17 address line 0 (pins) 2-33, 7-17 address line 1 (pins) 2-33 address line 14 (pins) 2-33, 3-19 address line 7 (pins) 2-20, 7-17 address strobe 10-6 address strobe (pins) 2-18, 2-21, 3-10, 3-20, 4-15, 5-25, 6-14, 7-12, 7-23, 7-24, 9-1, 10-6 address/data line 0 (pins) 2-3, 2-8, 2-14, 4-2, 4-7, 4-22, 5-1, 5-2, 5-22, 5-25, 5-28, 6-8, 6-13, 7-7, 7-8, 7-46, 9-1, 9-6, 9-9, 9-15, 9-29, 11-2, 11-6, 11-7, 11-11, 12-1, 12-18, 12-21 address/data line 7 (pins) 2-3, 2-8, 2-14, 4-2, 4-7, 4-22, 5-1, 5-2, 5-22, 5-25, 5-28, 6-8, 6-13, 7-7, 7-8, 7-46, 9-1, 9-6, 9-9, 9-15, 9-29, 11-2, 11-6, 11-7, 11-11, 12-1, 12-18, 12-21 address/data mux bus (ad7-ad0) 2-5, 2-7, 2-20, 7-1, 7-12, 7-16 addressing modes 4-12, 6-1, 6-6, 6-11, 7-4 adpu (bit in option) 3-9, 5-3, 12-13, 12-14 adr1 (registers) 12-15 adr4 (registers) 12-17 analog multiplexer 2-26 arithmetic instructions (instructions) 6-1, 6-2, 6-3, 6-11, 6-12 at-cut crystal 2-12, 2-15, 2-16 automatic clearing mechanism 5-27 CbC baud rate 5-3, 9-1, 9-5, 9-7, 9-18, 9-20, 9-26, 9-30 baud register (registers) 3-14 binary-coded decimal (bcd) 6-2 bit manipulation instructions (instructions) 4-12, 5-27, 6-11 block diagram 1-2, 1-3, 2-7, 8-3, 8-4, 9-1, 9-2, 9-3, 9-4, 9-19, 9-30, 9-31, 10-2, 10-3, 11-1, 11-2, 11-3 bootloader rom 4-2, 5-6 bootstrap mode 2-8, 2-20, 2-31, 2-37, 3-18, 4-2, 4-10, 4-15, 4-18, 4-19, 5-2, 5-3, 5-6, 5-13, 5-14, 5-22, 5-23, 9-7, 10-39 bootstrap rom 3-2, 5-3, 5-13 bprot register (registers) 4-10 branch instructions (instructions) 6-17 break, serial transmission 2-24, 4-9, 5-3, 5-23, 9-1, 9-3, 9-6, 9-10, 9-11, 9-15, 9-16, 9-25, 9-26 bulk erase, eeprom 4-5, 4-12 byte (bit in pprog) 4-11, 4-12, 4-13 byte erase, eeprom 4-5, 4-13 CcC ca (bit in adctl) 5-5, 6-8, 6-19, 12-16 cb (bit in adctl) 6-2, 12-16 cbyp (bit in test1) 3-12, 3-13, 10-11 cc (bit in adctl) 2-17, 2-18, 5-1, 5-2, 5-9, 5-11, 5-21, 5-23, 6-4, 6-5, 6-11, 12-14, 12-15, 12-16 ccf (bit in adctl) 12-14, 12-15 cd channel d select (bit in adctl) 6-11, 12-16 cforc register (registers) 10-38 chains, clock divider 9-7, 10-1, 10-5, 10-9 charge conservation 1 2-3, 12-4 charge pump 2-17, 2-18, 2-31, 4-4, 4-9, 4-25, 12-13 charge redistribution 12-1, 12-20 cheater latch 7-8 clock divider chains 10-1, 10-5, 10-9 clock monitor 1-2, 2-16, 3-13, 3-18, 5-5 clock monitor reset 5-7, 5-9 clock output (pins) 1-2, 1-6, 2-2, 2-8, 2-9, 2-11, 2-13, 2-15, 2-17, 2-18, 2-22, 2-25, 2-26, 2-33, 2-35, 2-36, 2-37, 3-8, 3-10, 3-11, 3-13, 4-1, 4-2, 4-4, 4-5, 4-6, 4-7, 4-8, 4-9, 4-10, 4-11, 4-12, 4-14, 4-16, 4-18, 4-19, 4-20, 4-21, 4-23, 4-24, 5-1, 5-2, 5-5, 5-8, 5-10, 5-25, 5-27, 6-1, 6-3, 6-6, 6-7, 7-2, 7-3, 7-8, 7-11, 7-16, 7-17, 7-19, 7-39, 7-40, 7-41, 7-42, 7-46, 7-47, 8-11, 9-1, 9-5, 9-6, 9-11, 9-13, 9-15, 9-21, 9-23, 9-30, 9-31, 9-33, 9-35, 10-1, 10-6, 10-18, 10-20, 10-36, 10-38, 10-42, 11-1, 11-2, 11-5, 11-6, 11-7, 11-8, 11-9, 11-10, 12-9, 12-12, 12-13, 12-17, 12-21 cme (bit in option) 3-9, 3-13, 5-9 compare inhibit 10-41, 10-42
motorola m68hc11 i-2 reference manual condition code 2-17, 3-12, 5-1, 5-23, 6-1, 6-2, 6-4, 6-12, 6-17, 8-7, 10-21, 11-2, 11-9 condition code register (ccr) 2-17, 2-18, 5-1, 5-2, 5-9, 5-11, 5-21, 5-23, 6-4, 6-5, 6-11, 8-7, 8-9, 10-21, 10-28 condition code register instructions (instructions) 6-17 config register (registers) 1-6, 2-1, 2-3, 2-16, 2-33, 3-3, 3-4, 3-10, 3-11, 3-19, 3-23, 4-1, 4-2, 4-4, 4-13, 4-18, 4-23, 5-2, 5-3, 5-4, 5-7, 5-8 configuration 2-28, 3-13, 4-1, 4-8, 4-18, 5-2, 5-3, 5-4, 5-8, 5-25, 7-2, 7-5, 7-15, 7-28, 7-43, 8-6, 8-8, 8-9, 8-10, 8-12, 9-6, 9-15, 10-11, 10-35 configuration mechanism 3-3 conversion sequence, a/d 12-3, 12-4, 12-13, 12-18, 12-20 cop watchdog 3-5, 3-13, 5-3, 5-4, 5-5, 5-6, 5-7, 10-5, 10-7, 10-13 coprst register (registers) 5-8 counter 4-26, 5-5, 5-11, 5-20, 5-24, 6-3, 6-4, 6-10, 8-11, 9-7, 9-8, 10-1, 10-5, 10-11, 10-15, 10-16, 10-35, 10-38, 10-39, 10-40, 11-1, 11-6, 11-7, 11-8, 11-9, 11-10, 11-11 counter bypass 10-11 cpha (bit in spcr) 8-2, 8-3, 8-8, 8-10, 8-11 cpol (bit in spcr) 8-1, 8-2, 8-8, 8-12, 8-13 cpu 1-2, 2-20, 2-21, 3-1, 3-7, 3-12, 4-3, 5-1, 5-2, 5-11, 5-21, 5-23, 5-24, 5-27, 6-1, 6-6, 6-10, 6-11, 7-11, 7-17, 9-1, 9-15, 10-19, 10-21, 11-2, 11-9 cr0 (bit in option) 3-9, 5-8, 10-14 cr1 (bit in option) 3-9, 5-8, 10-14 cr1,cr0 (bits in option) 3-9, 3-10 crystal oscillator 2-11, 2-15 csel (bit in option) 3-9, 4-10, 12-13 cwom (bit in pioc) 5-2, 7-2, 7-18, 7-46 CdC data direction registers (registers) 7-5 data direction, i/o 5-2, 7-1, 7-2, 7-5, 7-25, 7-26, 8-4, 8-6, 8-7, 9-5, 9-18, 10-35, 11-2, 11-4 data sampling 9-20, 9-25 data testing instructions (instructions) 6-11 ddra7 (bit in pactl) 7-1, 7-10, 10-35, 11-2, 11-4 ddrc register (registers) 5-2, 7-2, 7-18, 7-45 ddrd register (registers) 2-20, 7-2, 7-5, 7-25, 8-5, 8-6, 8-9, 9-5, 9-6, 9-18, 9-19, 9-31 derivatives 1-4, 2-37 disable resets 3-13, 5-8 disr (bit in test1) 3-11, 3-12, 3-13, 5-8, 5-9 divide instruction (instructions) 1-2, 2-14, 5-8, 5-9, 5-12, 6-1, 6-5, 6-11, 6-13, 9-7, 9-8, 9-30, 10-6, 10-25, 11-1, 11-2, 11-9, 11-10, 12-12, 12-16 dly (bit in option) 3-9, 4-12 double accumulator (ad) 1 -2, 6-1, 6-3 double-buffered receive 9-20 double-byte read 10-5, 10-16, 10-40 double-byte write 10-29 dwom (bit in spcr) 2-20, 3-16, 3-17, 7-3, 7-26, 8-6, 8-7, 8-10, 9-7, 9-19 CeC e 3-10 edge sensitive input 5-25 edgxa (bits in tctl2) 10-17, 10-18 edgxb (bits in tctl2) 10-17, 10-18 eelat (bit in pprog) 4-10, 4-11, 4-17 eeon (bit in config) 3-5, 4-4 eepgm (bit in pprog) 4-10, 4-12, 10-4 eeprom 1-2, 1-6, 2-2, 2-3, 2-16, 2-17, 2-18, 2-31, 2-33, 3-1, 3-3, 3-4, 3-5, 3-10, 3-11, 3-20, 4-1, 4-2, 4-4, 4-5, 4-6, 4-7, 4-8, 4-9, 4-10, 4-11, 4-12, 4-14, 4-16, 4-18, 4-19, 4-20, 4-23, 5-1, 5-2, 5-8, 5-25, 10-4, 10-31, 12-14 eeprom cell 4-6, 4-7, 5-2, 5-3 ega (bit in pioc) 5-2, 7-20, 7-24, 7-43, 7-47 erase (bit in pprog) 4-11, 4-12, 4-13 erase-before-write 4-21, 4-22, 4-23, 4-24 even (bit in pprog) 4-11, 11-6 expanded mode 1-2, 2-7, 2-8, 2-18, 2-20, 2-21, 2-33, 2-38, 4-15, 5-1, 5-26, 7-1, 7-11, 7-12 extal pin (pins) 2-11, 2-22, 5-1, 5-7 extended addressing 6-3, 6-7 external bus clock output 2-21, 2-33, 4-9, 4-10, 5-8, 7-11, 7-25, 7-43, 10-6, 10-42, 11-2, 12-13 external reset 5-6, 5-10 extra stop bit 9-9, 9-15 CfC fcm (bit in test1) 3-12, 3-13 fcop (bit in test1) 3-12, 3-13 fe (bit in scsr) 2-37, 5-3, 6-10, 9-6, 9-11, 9-28, 11-7 flag clearing 5-1, 10-12 floating gate 4-6, 4-7, 4-21, 4-25 floating input 2-22 foc5-foc1 (bits in cforc) 7-8, 10-39 fractional divide instruction (instructions) 5-12, 6-13 framing error 5-3, 9-6, 9-11, 9-14, 9-24, 9-25 free-running counter 10-1, 10-2, 10-5, 10-15, 10-16, 10-39 CgC ground 2-2, 2-7, 2-18, 2-22, 2-23, 2-24, 4-7, 4-8, 7-6, 7-39, 12-17, 12-18 ChC half flip-flop 9-19 handshake i/o 2-18, 2-20, 2-38, 5-26, 7-1, 7-2, 7-4, 7-5, 7-12, 7-14, 7-41 highest priority interrupt 2-8, 5-1 hnds (bit in pioc) 5-2, 7-2, 7-15, 7-42, 7-47 hprio register 3-2 hprio register (registers) 2-8, 2-37, 3-2, 5-1, 5-5, 5-13
m68hc11 motorola reference manual i-3 CiC i/o port a 2-19, 5-2, 7-1, 7-7, 7-11, 7-41, 9-6, 10-2, 10-29, 11-1, 11-2, 11-4 i/o port b 2-20, 5-1, 7-2, 7-4, 7-5, 7-11, 7-12, 7-13, 7-41, 7-42 i/o port c 2-20, 2-28, 5-2, 7-2, 7-4, 7-15, 7-16, 7-17, 7-18, 7-19, 7-20, 7-21, 7-22, 7-23, 7-41, 7-43, 7-46 i/o port d 2-19, 2-28, 5-2, 5-3, 7-2, 7-5, 7-25, 7-37, 7-38, 7-43, 8-5, 8-6, 8-7, 8-10, 8-14, 9-5, 9-6, 9-19 i/o port e 2-18, 2-19, 2-22, 2-25, 2-26, 5-2, 7-3, 7-39, 7-40, 7-41 icxf (bits in tflg1) 10-17, 10-41 icxi (bits in tmsk1) 10-17 idle (bit in scsr) 5-3, 9-5, 9-6, 9-10, 9-13, 9-28, 9-29 idle line 9-5, 9-10, 9-29 idle-line wake up 9-17, 9-29 ilie (bit in sccr2) 9-5, 9-10, 9-28 illegal opcode 1-2, 3-12, 3-18, 5-20, 5-21, 5-22, 6-20 immediate addressing (addressing modes) 6-6 index register (registers) 1-2, 4-19, 6-1, 6-2, 6-6, 6-9, 6-11, 6-15, 7-4 index register instructions (instructions) 6-15 indexed addressing (addressing modes) 6-2, 6-9, 6-16, 7-4, 10-15 inherent addressing (addressing modes) 6-10 init register (registers) 3-6, 4-2, 4-3, 5-1, 5-2, 7-4 initial conditions 5-1, 5-2, 5-21 input capture 3-18, 5-4, 10-2, 10-16, 10-17, 10-18, 10-19, 10-20, 10-22, 10-24, 10-26, 10-27, 10-41, 11-8 input capture pin 1 (pins) 10-18 input capture pin 2 (pins) 2-18, 2-19, 10-25 input capture pin 3 (pins) 2-18, 2-19, 5-25, 7-7, 10-25 input handshake 7-15, 7-41, 7-43, 7-44, 7-47 instruction set 1-1, 1-2, 6-1, 6-5, 6-11 integer divide in struction (instructions) 5-12, 6-13 interlocked 7-2, 7-16, 7-43 interrupt driven 10-20, 10-34 interrupt instructions (instructions) 6-19 interrupt mask bit 2-18, 5-1, 5-4, 5-12, 5-21, 5-23, 6-5, 8-7, 8-9, 10-28, 11-2, 11-9 interrupt process 5-14, 5-20, 10-22 interrupt request line (irq) (pins) 2-17, 2-31, 2-38, 3-9, 4-11, 5-4, 5-22, 5-23, 5-25, 6-5, 7-48, 10-28, 11-9 interrupts 1-2, 2-17, 2-38, 4-17, 5-1, 5-3, 5-6, 5-11, 5-20, 5-21, 5-23, 5-25, 5-26, 6-3, 6-5, 6-19, 7-46, 8-7, 9-10, 9-15, 9-16, 9-28, 10-1, 10-11, 10-12, 10-13, 10-21, 10-28, 10-37, 11-1, 11-2, 11-4, 11-5, 11-8, 11-9 invb (bit in pioc) 7-42, 7-47 irq 3-18 irqe (bit in option) 3-9, 5-25 irv (bit in hprio) 2-34, 2-37, 3-2, 3-3, 3-11, 3-15, 5-13, 5-14 ix (cpu index register x) 5-12, 5-24 iy (cpu index register y) 5-12, 5-24 CjC jump instructions (instructions) 6-17 ClC latchup 2-22, 2-24, 7-29, 7-31, 7-47, 8-6, 8-9, 8-10, 12-17, 12-18 level sensitive 2-17, 5-25 life expectancy (eeprom) 4-21 lir pin (pins)(debug aid) 2-8, 2-10, 2-29, 2-37, 3-2, 3-12 listing of timer examples 10-42 load instructions (instructions) 6-11 logic instructions (instructions) 6-11, 6-14 lvi (low voltage inhibit) 2-16, 5-10 CmC m (bit in sccr1) 1-1, 1-2, 1-4, 1-6, 2-1, 2-2, 2-3, 2-4, 2-5, 2-6, 2-7, 2-8, 2-10, 2-14, 2-17, 2-20, 2-21, 2-22, 2-23, 2-30, 2-31, 2-32, 2-33, 2-35, 2-36, 2-37, 2-38, 3-10, 4-1, 4-2, 4-3, 4-4, 4-9, 4-18, 4-20, 4-21, 4-24, 4-25, 4-26, 5-1, 5-2, 5-5, 5-9, 5-12, 5-14, 5-21, 5-22, 5-23, 5-25, 5-27, 6-1, 6-2, 6-6, 6-11, 6-13, 6-14, 6-19, 7-1, 7-3, 7-4, 7-6, 7-13, 7-16, 7-17, 7-18, 7-19, 7-20, 7-21, 7-22, 7-23, 7-25, 7-29, 7-30, 7-31, 7-32, 7-42, 7-43, 7-44, 7-47, 9-1, 9-6, 9-7, 9-8, 9-9, 9-10, 9-15, 9-20, 9-21, 9-26, 9-29, 9-30, 9-31, 10-35, 11-1, 11-6, 11-8, 11-10, 12-1, 12-12, 12-16, 12-17, 12-19 mark (sci data high level) 9-5, 9-9, 9-10, 9-15, 9-29, 12-1, 12-21 MC68HC11a8 pin assignments 2-2 MC68HC11d3/711d3 pin assignments 2-3 MC68HC11e9/711e9 pin assignments 2-4 mc68hc24 pin assignments 2-7 mda (bit in hprio) 2-8, 3-2, 3-3, 3-5, 3-11, 5-5, 5-13, 5-14, 7-12 measuring long time periods 10-24 miscellaneous instructions (instructions) 6-19 miso pin (pins) 2-20, 7-5, 7-29, 7-30, 8-2, 8-4, 8-5, 8-7, 8-10 moda pin 3-2 moda pin (pins) 2-8, 2-10, 2-22, 2-29, 3-1, 3-2, 3-5, 3-10, 3-20, 4-15, 5-5 modb pin 3-2 modb pin (pins) 2-8, 2-11, 2-18, 2-22, 2-30, 3-1, 3-2, 3-10, 3-11, 3-19, 3-20, 4-3, 4-15, 5-5 mode fault 7-29, 8-5, 8-6, 8-9 mode selection 2-7, 2-8, 5-4, 5-5 modf (bit in spsr) 8-7, 8-9 mosi pin (pins) 2-20, 7-5, 7-31, 7-32, 8-2, 8-4, 8-5, 8-7 mstr (bit in spcr) 7-32, 8-6, 8-7, 8-9 mul instruction (instructions) 5-12, 6-13, 10-24, 12-16, 12-19 mult (bit in adctl) 6-13, 12-16, 12-19 multiplexer (on a to d inputs) 2-26, 9-19, 9-20, 12-13, 12-14 multiply instruction (mul) (instruction) 5-12, 6-5, 6-11, 6-13, 9-27, 10-24
motorola m68hc11 i-4 reference manual CnC nf (bit in scsr) 9-6, 9-11, 9-12, 9-13, 9-21 nocop (bit in config) 3-4, 3-5, 3-13, 5-3, 5-7, 5-8 noise flag 9-3, 9-6, 9-13 non0return to zero (nrz) 9-1 nonmaskable interrupt 1-2, 2-17, 4-17, 5-11, 5-20, 5-21, 5-25 normal expanded mode 2-33, 3-10, 4-15 normal modes 2-10, 2-37, 4-2, 5-14, 10-10, 10-11 normal single-chip mode 3-10, 4-2, 4-15, 5-5 nosec (bit in config) 3-4, 4-4, 4-15 CoC oc1d register (registers) 7-10, 10-29, 10-35 oc1m register (registers) 5-3, 7-8, 7-10, 10-29, 10-35 oc1m7-oc1m3 (bits in oc1m) 7-8 oc2/oc1 pin (pins) 2-19 oc3/oc1 pin (pins) 2-19 oc4/oc1 pin (pins) 2-19 oc5/oc1 pin (pins) 2-19 occr (bit in test1) 3-12, 3-13 ocxf (bits in tflg1) 10-28, 10-30, 10-42 ocxi (bits in tmsk1) 10-30 odd (bit in pprog) 4-11, 8-14 oin (bit in pioc) 7-15, 7-42, 7-43, 7-47 ol5-ol2 (bits in tctl1) 7-8, 10-29, 10-32 om5-om2 (bits in tctl1) 7-8, 10-29, 10-32 option register (registers) 2-17, 3-6, 3-9, 3-13, 4-10, 4-12, 5-8, 5-9, 5-25, 10-14, 12-13 or (bit in scsr) 2-17, 2-20, 3-9, 3-16, 3-17, 5-2, 5-3, 5-25, 5-26, 6-14, 7-2, 7-5, 7-18, 7-20, 7-46, 8-6, 8-7, 9-5, 9-8, 9-10, 9-13, 9-20, 9-28, 10-15 oscillator 2-11, 2-15, 2-31, 2-33, 3-9, 4-3, 4-10, 5-5, 5-7, 6-5, 9-1, 10-1, 10-6, 12-13 output compare 2-2, 2-19, 3-18, 7-8, 10-1, 10-2, 10-4, 10-7, 10-16, 10-28, 10-30, 10-32, 10-33, 10-35, 10-36, 10-38, 10-39, 10-42, 11-2 output handshake 7-2, 7-5, 7-15, 7-41, 7-44, 7-45 overflow 3-18, 5-22, 6-4, 6-5, 10-1, 10-5, 10-7, 10-10, 10-11, 10-18, 10-21, 10-24, 10-39, 11-2, 11-5, 11-6, 11-8, 11-11 CpC pa6-pa3 (pins) 7-7, 7-9, 10-2 pa7 pin (pins) 2-18, 2-19, 7-1, 7-8, 7-10, 10-2, 10-35, 11-1, 11-4, 11-9 pacnt register (registers) 11-3, 11-6, 11-7, 11-8, 11-9, 11-12 pactl register (registers) 7-1, 10-13, 10-35, 11-2, 11-4 paen (bit in pactl) 11-2, 11-4 pai pin (pins) 2-18, 2-19, 5-3, 7-8, 11-1, 11-6, 11-7, 11-8, 11-9, 11-10 paif (bit in tflg2) 11-2, 11-5, 11-6, 11-8, 11-9 paii (bit in tmsk2) 3-8, 11-2, 11-6, 11-9 pamod (bit in pactl) 11-2, 11-5 paovf (bit in tflg2) 11-2, 11-5, 11-8, 11-11 paovi (bit in tmsk2) 3-8, 11-2, 11-5 parity 9-9, 9-10, 9-15 pedge (bit in pactl) 11-2, 11-5, 11-7, 11-9 periodic interrupt 10-1 ph2 (internal clock signal) 5-7, 7-11, 7-42, 7-46, 8-11, 9-30, 9-33, 10-6, 10-16, 10-41, 11-3, 11-9 phase 2 (ph2) 10-6, 11-9 pin logic diagrams 7-6 pioc register (registers) 5-2, 7-2, 7-15, 7-16, 7-41, 7-46 plastic leaded chip carrier (plcc) 2-1, 2-2 pls (bit in pioc) 7-15, 7-16, 7-42, 7-43, 7-47 port replacement unit (mc68hc24) 1-2, 2-1, 2-6, 2-38, 5-26, 7-1, 7-12, 7-43 port replacement unit (pru) 2 -1, 2-38, 3-11, 5-26, 7-12, 7-13, 7-16, 7-23, 7-25 porta register (registers) 7-1, 10-2 portb register (registers) 7-2, 7-15, 7-42 portc register (registers) 7-2, 7-4, 7-5, 7-15, 7-43 portcl register (registers) 7-2, 7-4, 7-5, 7-15, 7-43 portd register (registers) 9-6, 9-18, 9-19 postscaler 10-5 power consumption 1-1, 2-10, 2-27, 2-34, 4-3, 5-22, 6-20, 7-21, 10-7 poweron reset 5-5, 5-6, 5-7 power-on reset (por) 5-7, 7-1, 7-2, 7-4, 7-5, 7-11, 7-12, 7-13, 7-16, 7-17, 7-18, 7-21, 7-23, 7-37, 7-39, 7-40, 7-42, 7-43, 9-6, 9-18, 9-19 pprog register (registers) 3-4, 4-10 pr0 (bit in tmsk2) 4-12, 5-11, 6-1, 10-10, 10-38, 10-41, 11-10 pr1 (bits in tmsk2) 3-8, 10-10, 10-38, 10-41, 11-10 preamble 9-3, 9-10, 9-16, 9-17, 9-31 prebyte, opcode 6-1, 6-6, 6-11 prescaler 3-8, 5-2, 9-7, 10-1, 10-5, 10-7, 10-10, 10-41 program control instructions (instructions) 6-17 programmable prescaler 10-1, 10-7 programming voltage 2-31, 4-8, 4-11, 4-25 program-more-zeros 4-21, 4-22 protection device 2-25, 7-6, 12-17 psel3-psel0 (bits in hprio) 3-2, 5-4, 5-14 pulse accumulator 1-2, 5-3, 5-25, 7-1, 7-7, 9-6, 10-2, 10-5, 10-6, 10-20, 10-35, 11-1, 11-2, 11-3, 11-4, 11-5, 11-6, 11-7, 11-8, 11-9, 11-11 pulse accumulator block diagram 11-2 pulse width 10-1, 10-2, 10-20, 10-22, 11-8 pulsed operation 7-16 pulse-width modulation (pwm) 10-28, 10-36 CqC queued idle 9-11, 9-15, 9-17 CrC r/w pin (pins) 2-33, 2-37, 3-3, 5-14, 7-14, 7-15 r8 (bit in sccr1) 9-3, 9-9
m68hc11 motorola reference manual i-5 ram 1-2, 2-3, 2-5, 2-7, 2-11, 2-30, 2-33, 2-38, 3-1, 3-2, 3-5, 3-6, 3-15, 3-16, 4-1, 4-2, 4-3, 4-4, 4-14, 4-17, 5-2, 5-6, 5-13, 5-24, 5-27, 6-4, 6-8, 7-4, 8-15, 8-16, 10-21, 11-7 ram standby 2-11, 4-2, 4-3 ram3-ram0 (bits in init) 3-6, 4-3 random access memory (ram) 1-2, 2-3, 2-5, 2-7, 2-11, 2-30, 2-33, 2-38, 3-1, 3-2, 3-5, 3-6, 3-15, 3-16, 4-1, 4-2, 4-3, 4-4, 4-14, 4-17, 5-2, 5-6, 5-13, 5-24, 5-27, 6-4, 6-8, 7-4, 8-15, 8-16, 10-21, 11-7 range 2-1, 2-14, 2-23, 6-9, 6-10, 6-18, 7-6, 7-39, 10-1, 10-2, 10-7, 10-18, 10-21, 10-28, 11-8, 12-1 rboot (bit in hprio) 3-2, 3-11, 3-15, 5-13, 10-5 rc oscillator 4-10, 12-13 rckb (bit in baud) 3-14, 9-8 rdr register (registers) 5-3, 5-27, 9-5, 9-6, 9-9, 9-10, 9-12, 9-21, 9-35, 9-36 rdrf (bit in scsr) 5-3, 5-27, 9-5, 9-6, 9-10, 9-12, 9-21, 9-35, 9-36 re (bit in sccr2) 2-8, 2-10, 2-15, 2-29, 4-13, 5-3, 5-4, 5-5, 5-6, 5-25, 6-10, 6-19, 7-3, 7-27, 9-5, 9-11, 9-20, 12-1 read-only memory (rom) 1-2, 2-1, 2-2, 2-15, 2-33, 2-38, 3-2, 3-4, 3-7, 3-10, 3-11, 3-13, 4-1, 4-14, 4-15, 4-18, 5-2, 5-3, 5-6, 5-13, 6-9, 7-1 real-time interrupt 1-2, 3-18, 5-3, 10-1, 10-11, 10-12, 10-13, 11-4 receiver 2-19, 5-3, 7-27, 8-6, 9-1, 9-3, 9-4, 9-5, 9-7, 9-8, 9-11, 9-15, 9-20, 9-29, 9-35 receiver wake up 9-1, 9-5, 9-11, 9-15, 9-21, 9-29 reg3-reg0 (bits in init) 3-7 relative addressing 6-6, 6-10 reset pin (pins) 2-8, 2-16, 2-22, 2-30, 3-2, 5-1, 5-5 resolution 1-2, 5-12, 5-13, 5-18, 5-19, 5-20, 9-22, 9-26, 10-4, 10-7, 10-16, 10-20, 10-35, 10-36, 11-9 return from interrupt (rti) 5-20, 6-3, 10-12 return instructions (instructions) 6-18 rie (bit in sccr2) 9-5, 9-10, 9-28 romon (bit in config) 2-33, 3-4, 3-5, 3-10, 3-13 rotate instructions (instructions) 6-11, 6-14 row (bit in pprog) 4-11, 4-12, 4-13 row erase, eeprom 4-5 rtif (bit in tflg2) 10-12 rtii (bit in tmsk2) 3-8, 10-12, 10-13 rtr1,rtr0 (bits in pactl) 10-12, 10-13 rwu (bit in sccr2) 9-5, 9-11, 9-15, 9-28, 9-29 rxd pin (pins) 2-20, 3-18, 7-25, 7-26, 9-3, 9-5, 9-6, 9-13, 9-20, 9-21 CsC sample and hold 7-39, 12-1 sbk (bit in sccr2) 9-6, 9-11, 9-16 scan (bit in adctl) 12-16, 12-19 sccr1 register (registers) 9-3, 9-5, 9-9, 9-15 sccr2 register (registers) 9-5, 9-10, 9-15, 9-17, 9-29 scdr register (registers) 9-3, 9-5, 9-6, 9-9, 9-14, 9-16, 9-28, 9-33, 9-34 sci (serial communications interface) 3-18 sck pin (pins) 2-20, 7-33, 7-34, 8-1, 8-2, 8-4, 8-5, 8-6, 8-7, 8-10, 8-11 scp1,scp0 (bits in baud) 3-14, 9-7, 9-8, 9-30, 9-32 scr2-scr0 (bits in baud) 9-8, 9-30, 9-32 scsr register (registers) 9-3, 9-5, 9-6, 9-11, 9-16 security 3-4, 4-2, 4-4, 4-14, 5-4 selective-write 4-17, 4-23, 4-25 send break 5-3, 9-3, 9-6, 9-11, 9-16 serial communications interface (sci) 1-2, 2-19, 2-20, 3-1, 3-3, 3-12, 3-14, 5-3, 5-13, 5-15, 5-20, 5-27, 7-2, 7-5, 7-25, 7-27, 8-6, 9-1, 9-2, 9-4, 9-5, 9-7, 9-8, 9-9, 9-10, 9-11, 9-14, 9-18, 9-20, 9-30, 10-7 serial peripheral interface (spi) 1-2, 2-20, 3-1, 3-17, 5-3, 7-2, 7-3, 7-5, 7-25, 7-29, 8-1, 8-2, 8-3, 8-4, 8-5, 8-6, 8-7, 8-8, 8-9, 8-10, 8-13, 8-14, 8-16, 9-1, 9-5, 9-6, 9-19 service routine 5-8, 5-11, 5-22, 5-24, 5-27, 6-3, 6-5, 9-16, 10-8, 10-11, 10-17, 10-20, 10-31, 10-37, 11-5, 11-6, 11-8, 11-9 shift instructions (instructions) 6-11, 6-14 single-chip mode 2-8, 2-18, 2-20, 2-21, 2-38, 4-2, 4-14, 5-1, 5-5, 5-25, 5-26, 7-1, 7-11, 7-12 smod (bit in hprio) 2-8, 3-2, 3-3, 3-6, 3-11, 5-5, 5-13 software interrupt 5-23, 6-19 spcr register (registers) 2-20, 3-16, 7-3, 8-1, 8-6, 8-7, 9-5, 9-6 spdr register (registers) 8-3, 8-6, 8-8, 8-9, 8-11, 8-12 spe (bit in spcr) 7-13, 7-16, 7-23, 7-25, 8-6, 8-7, 8-9 special bootstrap mode 2-31, 3-15, 4-2, 4-10, 4-18, 4-19, 5-3, 5-6, 5-13, 5-14 special modes 2-10, 5-13, 10-11 special test mode 2-33, 3-14, 3-19, 5-6, 5-13, 5-14 spi (serial peripheral interface) 1-2, 2-20, 3-1, 3-17, 3-18, 5-3, 7-2, 7-3, 7-5, 7-25, 7-29, 8-1, 8-2, 8-3, 8-4, 8-5, 8-6, 8-7, 8-8, 8-9, 8-10, 8-13, 8-14, 8-16, 9-1, 9-5, 9-6, 9-19 spi block diagram 8-3 spi transfer formats 8-1, 8-10 spie (bit in spcr) 8-7, 8-9 spif (bit in spsr) 8-7, 8-8, 8-10, 8-12 spr1,spr0 (bits in spcr) 8-8, 8-11 spsr register (registers) 8-6, 8-8, 8-9 ss pin (pins) 2-20, 7-35, 7-36, 8-2, 8-4, 8-6, 8-9, 8-11 stack manipulation instructions (instructions) 6-11, 6-15 stack pointer (sp) 5-2, 5-21, 5-24, 6-3, 6-11, 6-15 staf (bit in pioc) 5-2, 7-2, 7-23, 7-43, 7-46 stai (bit in pioc) 5-2, 7-46 standby voltage 2-8, 2-11, 2-18, 2-30, 3-2, 4-3 start bit (sci) 9-1, 9-9, 9-13, 9-15, 9-20, 9-21, 9-22, 9-23, 9-24, 9-25 stop and wait instructions (instructions) 6-19 stop bit 9-1, 9-3, 9-9, 9-15, 9-20, 9-21, 9-33 stop disable 5-9, 6-4, 6-17 stop instruction (instructions) 1-2, 2-9, 2-10, 3-1, 3-2, 3-9, 4-3, 5-2, 5-9, 5-22, 6-4, 6-17, 6-19, 7-17, 10-6 stop mode 2-10, 2-11, 4-3, 5-2, 5-22, 6-20, 7-23, 7-24, 10-6 store instructions (instructions) 6-11
motorola m68hc11 i-6 reference manual stra pin (pins) 2-18, 2-20, 2-21, 3-10, 4-15, 5-2, 5-25, 7-1, 7-2, 7-5, 7-12, 7-16, 7-23, 7-24, 7-25, 7-41, 7-48 strb pin (pins) 2-20, 2-21, 3-10, 7-1, 7-2, 7-12, 7-14, 7-15, 7-16, 7-41, 7-48 strobe 2-3, 2-8, 2-14, 4-2, 4-7, 4-22, 5-1, 5-2, 5-22, 5-25, 5-28, 6-8, 6-13, 7-7, 7-8, 7-46, 9-1, 9-6, 9-9, 9-15, 9-29, 11-2, 11-6, 11-7, 11-11, 12-1, 12-18, 12-21 subroutine call instructions (instructions) 6-3, 6-18, 10-11 successive approximation register (sar) 12-4, 12-13 supply voltage 2-7, 2-18, 2-22, 2-23, 2-33, 3-2, 4-1, 4-3, 4-4, 4-25, 5-6, 5-7, 7-6, 7-39, 7-47, 12-13, 12-17 swi 3-17, 3-18, 5-20, 5-23, 6-19 CtC t8 (bit in sccr1) 9-3, 9-9, 9-15 tc (bit in scsr) 5-3, 9-1, 9-3, 9-6, 9-7, 9-10, 9-12, 9-15, 9-16, 9-34 tcie (bit in sccr2) 9-3, 9-10, 9-16 tclr (bit in baud) 3-14, 9-7 tcnt register (registers) 10-5, 10-30, 10-40 tcon 3-12 tcon (bit in test1) 3-13 tctl1 register (registers) 10-29, 10-32 tctl2 register (registers) 10-17, 10-23 tdr register (registers) 5-3, 9-1, 9-3, 9-6, 9-9, 9-10, 9-12, 9-14, 9-33 tdre (bit in scsr) 5-3, 9-1, 9-3, 9-6, 9-10, 9-12, 9-14, 9-15, 9-33 te (bit in sccr2) 2-21, 5-9, 5-22, 5-23, 6-14, 6-19, 7-29, 9-5, 9-7, 9-10, 9-14, 9-16, 9-31, 9-32 termination of unused pins 2-21 test instruction (instructions) 3-19, 5-9, 5-22, 5-23, 6-14, 6-19, 10-11 test mode 2-33, 4-2, 5-6, 5-13, 9-8, 10-11 test1 register (registers) 3-11, 3-12, 3-13, 5-9, 6-14, 10-11 tflg1 register (registers) 10-14, 10-17, 10-30, 10-31 tflg2 register (registers) 10-11, 11-5 tie (bit in sccr2) 9-3, 9-10, 9-16 tilop (bit in test1) 3-12 time accumulation (pulse accumulator) 10-6, 11-1, 11-7, 11-8, 11-9, 11-10 timer 1-2, 2-3, 2-4, 2-18, 2-19, 3-8, 3-9, 3-12, 3-13, 3-18, 5-2, 5-5, 5-6, 5-7, 5-25, 5-27, 7-1, 7-7, 10-1, 10-2, 10-3, 10-5, 10-10, 10-11, 10-14, 10-15, 10-16, 10-28, 10-39, 10-40, 10-42, 11-1, 11-2, 11-7, 11-8, 11-10 tmsk1 register (registers) 10-28 tmsk2 register (registers) 3-6, 3-8, 10-6, 10-10, 10-41 toc1 register (registers) 10-37 toc2 register (registers) 10-37 toc3 register (registers) 10-37 tof (bit in tflg2) 10-10, 10-11, 10-15, 10-25, 10-26, 10-27 toi (bit in tmsk2) 3-8, 10-10, 10-11 transfer characteristic 12-7 transfer instructions (instructions) 6-11 transmission gate 7-6, 7-7 transmitter 2-20, 5-3, 5-27, 7-5, 7-28, 8-6, 9-1, 9-2, 9-5, 9-7, 9-9, 9-14, 9-18, 9-30, 9-31, 9-33 trapped charge 4-9, 4-21 txd pin (pins) 2-20, 3-17, 7-5, 7-27, 7-28, 9-5, 9-6, 9-8, 9-10, 9-14, 9-15, 9-18, 9-19, 9-31, 9-32 CuC universal asynchronous receiver/transmitter (uart) (see sci) 9-1 CvC vdd pin (pins) 2-7, 2-18, 2-22, 2-23, 2-33, 3-2, 4-1, 4-3, 4-4, 4-25, 5-6, 5-7, 7-6, 7-39, 7-47, 12-13, 12-17 vector (interrupt) 2-33, 2-38, 3-18, 4-2, 5-1, 5-2, 5-4, 5-5, 5-6, 5-12, 5-22, 5-23, 5-24, 5-25, 5-26, 6-3, 6-5, 6-19, 7-48, 9-16, 10-21, 10-28, 10-32, 10-39, 11-1, 11-2 vector (reset) 2-33, 2-38, 4-2, 5-1, 5-2, 5-4, 5-5, 5-6, 5-12, 5-22, 5-23, 5-24, 5-25, 5-26, 6-3, 6-5, 6-19, 7-48, 9-16, 10-21, 10-28, 10-32, 10-39, 11-1, 11-2 vpp pin (pins) 2-31, 4-8, 4-11, 4-25 vrefh pin (pins) 2-18, 2-22, 7-39 vrefl pin (pins) 2-18, 2-22, 7-39 vss pin (pins) 2-2, 2-7, 2-18, 2-22, 2-23, 2-24, 4-7, 4-8, 7-6, 7-39, 12-17, 12-18 vstby pin (pins) 2-8, 2-11, 2-18, 2-30, 3-2, 4-3, 4-4 CwC wait for interrupt 6-19 wait for interrupt instruction (instructions) 1-2, 5-25, 6-19 wait mode 6-19, 7-21 wake (bit in sccr1) 9-3, 9-5, 9-10, 9-11, 9-29 watchdog 1-2, 2-16, 3-10, 5-3, 5-5, 5-6, 5-7, 5-8, 10-1, 10-5, 10-7, 10-13 wcol (bit in spsr) 8-8 write collision 8-8, 8-9, 8-10, 8-14 write-erase cycles 4-9, 4-16, 4-21 CxC x bit 2-17, 5-12, 5-21, 6-6, 6-17 xirq pin 3-18 xirq pin (pins) 2-17, 5-11, 5-21, 5-25, 6-6, 6-17 xtal pin (pins) 2-11, 2-14 CzC zap 2-24

m 68hc11rm/ad motorol a rese r v e s th e r igh t t o ma k e change s withou t fu r the r notic e t o a n y product s herein . motorol a ma k e s n o w arrant y , representatio n o r gua r ante e regardin g th e suitabilit y o f its product s f o r a n y pa r ticula r pu r pos e , no r doe s motorol a assum e a n y liabilit y a r isin g ou t o f th e applicatio n o r us e o f a n y produc t o r circuit , an d speci?call y disclaim s a n y an d al l liabilit y , includin g withou t limitatio n consequentia l o r incidenta l damage s . " t ypical " parameter s whic h m a y b e pr o vide d i n motorol a dat a sheet s and/o r speci?cation s ca n an d d o v a r y i n dif f erent application s an d actua l per f o r manc e m a y v a r y o v e r tim e . al l operatin g parameter s , includin g " t ypicals " mus t b e v alidate d f o r eac h custome r applicatio n b y customer' s technica l e xpe r t s . motorol a doe s no t co n v e y a n y licens e unde r it s paten t r ight s no r th e r ight s o f other s . motorol a product s ar e no t designed , intended , o r autho r i z e d f o r us e a s component s i n systems intende d f o r surgica l implan t int o th e bod y , o r othe r application s intende d t o suppo r t o r sustai n li f e , o r f o r a n y othe r applicatio n i n whic h th e f ailur e o f th e motorol a produc t coul d creat e a situatio n wher e persona l inju r y o r deat h m a y occu r . shoul d bu y e r purchas e o r us e motorol a product s f o r a n y suc h unintende d o r unautho r i z e d application , bu y e r shal l indemnif y an d hold motorol a an d it s of?cer s , empl o y ee s , subsidia r ie s , af?liate s , an d dist r i b utor s ha r mles s agains t al l claim s , cost s , damage s , an d e xpense s , an d reasona b l e atto r n e y f ee s a r isin g ou t o f , directl y o r indirectl y , a n y clai m o f persona l inju r y o r deat h associate d wit h suc h unintende d o r unautho r i z e d us e , e v e n i f suc h clai m allege s tha t motorol a w a s negligen t regardin g the design or manu f acture of the pa r t. motorola and are registered tradema r ks of motorola, inc. motorola, inc. is an equal oppo r tunity/af? r mati v e action empl o y e r . h o w to reach us: usa/eu r ope/locations not listed: motorola literature dist r i b ution, p . o . b o x 5405, de n v e r , colorado 80217, 1-800-441-2447 or 1-303-675-2140. customer f ocus cente r , 1-800-521-6274 j a p an: nippon motorola ltd.: sp d , strategic planning of?c e , 141, 4-32-1 nishi-gotanda, shinag a w a-ku, t ok y o , j apan. 03-5487-8488 asia/ p a cific : motorol a semiconductor s h.k . ltd. , 8 b t a i pin g indust r ia l p a r k , 5 1 tin g k o k road , t a i p o , n. t . , hon g k ong . 852-26629298 mfax?, moto r ola f ax ba c k system : rm f ax0@email.sp s .mot.com; http://sp s .motorola.com/m f ax/; t ouch t one, 1-602-244-6609; us and canada on l y , 1-800-774-1848 home p a ge: http://motorola.com/sps/ m f ax is a tradema r k of motorola, inc. ? motorola , inc. , 199 6 previou s editio n 1991


▲Up To Search▲   

 
Price & Availability of MC68HC11

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X